Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
886 views
in Technique[技术] by (71.8m points)

reactjs - React 16.8.4 Uncaught TypeError: (0 , _react.useState) is not a function

Can someone help me understand why I'm having this error? I just recently transferred to React 16.8.4 from React 15 and changed one class component into a functional component with hooks, unfortunately it complains that useState is not a function and I don't think I did anything wrong with how I used it...

React is complaining about this line const [isChanged, setIsChanged] = useState(false);

It's not a problem with the certain component, I can't use useState or any hooks for that matter ANYWHERE, app doesn't break, but component doesn't load and I get and error in the console.

here is the screenshot of the error

here are my dependencies.

"dependencies": {
        "2gis-maps": "^3.5.15",
        "babel-core": "^6.24.0",
        "babel-loader": "^7.0.0",
        "babel-plugin-react-html-attrs": "^2.0.0",
        "babel-plugin-transform-class-properties": "^6.23.0",
        "babel-plugin-transform-decorators-legacy": "^1.3.4",
        "babel-preset-env": "^1.6.1",
        "babel-preset-react": "^6.23.0",
        "babel-preset-stage-0": "^6.22.0",
        "bootstrap-loader": "^2.0.0-beta.22",
        "bootstrap-sass": "^3.3.7",
        "compression": "^1.7.0",
        "compression-webpack-plugin": "^1.0.0",
        "create-react-class": "^15.6.2",
        "css-loader": "^0.27.3",
        "cssnano": "^3.10.0",
        "detect-it": "^3.0.4",
        "es6-promise": "^4.1.1",
        "express": "^4.15.2",
        "express-static-gzip": "^0.3.0",
        "extract-text-webpack-plugin": "^4.0.0-beta.0",
        "fast-crc32c": "^1.0.4",
        "file-loader": "^3.0.1",
        "fix-orientation": "^1.1.0",
        "fs": "0.0.2",
        "fs-extra": "^5.0.0",
        "if-env": "^1.0.0",
        "ilyabirman-likely": "^2.3.0",
        "imports-loader": "^0.7.1",
        "intl": "^1.2.5",
        "intl-locales-supported": "^1.0.0",
        "isomorphic-fetch": "^2.2.1",
        "jquery": "^3.5.1",
        "js-file-downloader": "^1.1.5",
        "merge": "^1.2.1",
        "node-sass": "^4.14.1",
        "optimize-css-assets-webpack-plugin": "^3.1.1",
        "prop-types": "^15.6.0",
        "react": "^16.8.4",
        "react-autosize-textarea": "^5.0.0",
        "react-bootstrap": "^0.32.1",
        "react-bootstrap-dialog": "^0.10.0",
        "react-calendar": "^2.14.0",
        "react-cookie": "^1.0.4",
        "react-device-detect": "^1.6.1",
        "react-document-meta": "^2.1.2",
        "react-dom": "^16.8.4",
        "react-emojione": "^5.0.0",
        "react-i18nify-lite": "^1.0.0",
        "react-infinite-calendar": "^2.3.1",
        "react-number-format": "^2.0.2",
        "react-otp-input": "^1.0.1",
        "react-pull-to-refresh": "^1.1.2",
        "react-redux": "^5.1.0",
        "react-router": "^5.2.0",
        "react-router-bootstrap": "^0.23.3",
        "react-router-dom": "^5.2.0",
        "react-select": "^1.2.1",
        "react-simple-timefield": "^3.0.0",
        "react-spreadsheet-grid": "^1.4.3",
        "react-swipeable": "^4.3.0",
        "react-tooltip": "^3.8.4",
        "react-webcam": "^4.0.0",
        "redux": "^4.0.5",
        "redux-thunk": "^2.3.0",
        "resolve-url-loader": "^2.0.2",
        "rmc-picker": "^5.0.10",
        "sass-loader": "^6.0.3",
        "style-loader": "^0.16.0",
        "tether": "^1.4.0",
        "tls": "0.0.1",
        "ua-format-js": "0.0.3",
        "uglifyjs-webpack-plugin": "^2.1.1",
        "url-loader": "^0.6.0",
        "uuid": "^3.2.1",
        "warning": "^3.0.0",
        "webpack": "^4.29.0",
        "webpack-cli": "^3.2.1",
        "webpack-dev-server": "^3.11.0",
        "webpack-shell-plugin": "^0.5.0",
        "webpack-visualizer-plugin": "^0.1.11"
    },

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...