Open altobellibm opened 2 years ago
Qrcode appears once, and after that, the message "Buffer is not defined"
i'm using react with typescript template
follow my package.json file:
_``` { "name": "pix-react-test", "version": "0.1.0", "private": true, "dependencies": { "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^12.1.4", "@testing-library/user-event": "^13.5.0", "@types/jest": "^27.4.1", "@types/node": "^16.11.26", "@types/react": "^17.0.44", "@types/react-dom": "^17.0.15", "buffer": "^6.0.3", "pix-react": "^1.0.3", "react": "^18.0.0", "react-dom": "^18.0.0", "react-scripts": "5.0.0", "typescript": "^4.6.3", "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" ] } }
Tive o mesmo problema, mas esse código resolveu import * as buffer from "buffer"; window.Buffer = buffer.Buffer;
import * as buffer from "buffer"; window.Buffer = buffer.Buffer;
https://rodriguesabner1.medium.com/pix-qrcode-din%C3%A2mico-usando-reactjs-f449bc015d7d
Qrcode appears once, and after that, the message "Buffer is not defined"
i'm using react with typescript template
follow my package.json file:
_``` { "name": "pix-react-test", "version": "0.1.0", "private": true, "dependencies": { "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^12.1.4", "@testing-library/user-event": "^13.5.0", "@types/jest": "^27.4.1", "@types/node": "^16.11.26", "@types/react": "^17.0.44", "@types/react-dom": "^17.0.15", "buffer": "^6.0.3", "pix-react": "^1.0.3", "react": "^18.0.0", "react-dom": "^18.0.0", "react-scripts": "5.0.0", "typescript": "^4.6.3", "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" ] } }