mqtt-react-hooks
mqtt-react-hooks copied to clipboard
Uncaught ReferenceError: Buffer is not defined
Right now, every newly created example will fail to run in the browser, with the above error. This seems to be related to an import referenced in this issue, but I just can't seem to locate it in the code of " mqtt-react-hooks". Also mentioned in this issue, so many MQTT libs have this problem right now.
To reproduce the issue:
- use npx to create a basic app
- copy instructions from https://github.com/VictorHAS/mqtt-react-hooks/blob/master/README.md
- run in browser to see the error
Can reproduce every time. Some suggest to solve this by downgrading "react-script", but that's not a real fix and causes other problems.
package.json contents:
{
"name": "mqtt-demo-react",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"mqtt-react-hooks": "^3.0.0-alpha.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"url": "^0.11.0",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}