gpt4 book ai didi

javascript - 未捕获的类型错误 : Cannot read property 'BlobBuilder' of undefined

转载 作者:行者123 更新时间:2023-12-01 04:09:48 24 4
gpt4 key购买 nike

我正在使用 Socket.IO 在 RethinkDB 和 React 之间来回传输信息。我不断得到

Uncaught TypeError: Cannot read property 'BlobBuilder' of undefined

whenever I try to run the file and, after some sleuthing, I was able to figure out that it came from my socket listener files. Here's one for an example:

// ./socket-listeners/inventory-listener.js
// imported into index.jsx

import io from 'socket.io-client';
const socket = io.connect('/');

const InventorySocketListener = (store) => {
socket.on('item:insert', (item) => {
store.dispatch({
type: 'item:insert',
item
});
});

socket.on('item:update', (item) => {
store.dispatch({
type: 'item:update',
item
});
});

socket.on('item:delete', (item) => {
store.dispatch({
type: 'item:delete',
item
});
});
};

export default InventorySocketListener;

如您所见,我在那里没有 BlobBuilder,而且我自己的搜索告诉我它已被弃用 (MDN)。我也确保更新了我的所有 npm 包。然而,在我的一生中,我无法弄清楚这到底是从哪里来的,也不知道如何解决它。想法?谢谢!

最佳答案

我对此进行了研究,结果发现问题最终出在“socket.io-client”的导入方式上。修复最终是import io from 'socket.io-client/dist/socket.io';

关于javascript - 未捕获的类型错误 : Cannot read property 'BlobBuilder' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41582453/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com