Closed afternoon2 closed 3 years ago
I'd assume that is somehow a problem with your bundler. Looking at that file, it contains
var import_react2 = __toModule(require("react"));
So that should definitely be there.
Did you solve this? I have the same problem
i have same error. just add '/react' for importing from query. importing is different in react.
import { createApi } from '@reduxjs/toolkit/query' // don't use this
/* React-specific entry point that automatically generates
hooks corresponding to the defined endpoints */
import { createApi } from '@reduxjs/toolkit/query/react' // use this one
when i import getUsersQuery then the error is showing. how to solve this error
Unhandled Thrown Error! (0 , _feature_api_apiSliceWEBPACK_IMPORTED_MODULE_2__.useGetUsersQuery) is not a function TypeError: (0 , _feature_api_apiSliceWEBPACK_IMPORTED_MODULE_2__.useGetUsersQuery) is not a function at Home (http://localhost:3000/static/js/bundle.js:850:78) at renderWithHooks (http://localhost:3000/static/js/bundle.js:30230:22) at mountIndeterminateComponent (http://localhost:3000/static/js/bundle.js:33516:17) at beginWork (http://localhost:3000/static/js/bundle.js:34812:20) at beginWork$1 (http://localhost:3000/static/js/bundle.js:39775:18) at performUnitOfWork (http://localhost:3000/static/js/bundle.js:39044:16) at workLoopSync (http://localhost:3000/static/js/bundle.js:38967:9) at renderRootSync (http://localhost:3000/static/js/bundle.js:38940:11) at recoverFromConcurrentError (http://localhost:3000/static/js/bundle.js:38432:24) at performConcurrentWorkOnRoot (http://localhost:3000/static/js/bundle.js:38344:26)
Hello! I'm not sure if this is a RTK-Query related issue, but I've been digging the web for a solution for about 2 days now 😬
I've got a package inside a lerna-driven monorepo, which is an embedded React app. I'm using Redux toolkit for state management, and I wanted to use RTK-query for data fetching as well.
Everything works fine in the browser, but when it comes to testing, I'm getting following error on and on:
Error: Uncaught [TypeError: (0 , import_react2.useState) is not a function]
It is related to the
@reduxjs/toolkit/dist/query/react/rtk-query-react.cjs.development.js:256:49
line in the bundle file:I've got
^17.0.2
React and ReactDOM versions. Jest configuration looks as below:The service looks as below:
And the failing test component inside the suite: