Closed Babeev closed 2 years ago
If I comment out this lines no errors appear and the rest works well
Unfortunately I don't think there's anything we can do here. We know the library itself works right, and works right with React. I have to assume this is an issue with your bundler config / project setup somehow.
Given that, and also that we don't use RN ourselves, I'm afraid I don't have any particular suggestions for what to change to fix this. Sorry!
The only thing I can suggest is to use the non-react entry point for creatApi
, which won't generate the hooks that are causing issues:
import { createApi } from '@reduxjs/toolkit/query';
Looks like they are specifically trying to use RTKQ with React here, so I don't think that's going to solve the issue.
I am a bit confused by seeing an RN project set up with Webpack - I thought those were usually bundled with Metro. I guess it's being cross-compiled with react-native-web
.
I can only assume that somehow react
itself isn't being found by the bundler in this case.
I am currently using RTKQ with a Expo React Native Web (hence webpack) setup at work and it works fine. This is really very very specific to your setup, I'm sorry!
Looks like they are specifically trying to use RTKQ with React here, so I don't think that's going to solve the issue.
I am a bit confused by seeing an RN project set up with Webpack - I thought those were usually bundled with Metro. I guess it's being cross-compiled with
react-native-web
.I can only assume that somehow
react
itself isn't being found by the bundler in this case.
Yes, I using react-native-web for setting up cross-platform app without expo. I have example repo for reproducing error: github.com/Babeev/react-native
For reproducing please open src/pages/Auth/controller.ts and uncomment line 12 or line 13. After this you will see the error
If this is NEXT js Then converting the component into client component using 'use client'will solve this issue i had solved the similar issue just now
In The createSlice check the spelling of reducers It should be reducers: {} I had the same error because I used reducer
Had the same issue solved it by adding "use client"
If this is NEXT js Then converting the component into client component using 'use client'will solve this issue i had solved the similar issue just now
You are a life saver @Yogeshthangm , thanks
If this is NEXT js Then converting the component into client component using 'use client'will solve this issue i had solved the similar issue just now
Yes, that's right
Use "Use Client" if you are using next js. It works!
I setting up react-native-web app with redux-toolkit and have an error: Uncaught TypeError: (0 , react__WEBPACK_IMPORTED_MODULE_1__.useState) is not a function at rtk-query-react.esm.js
This error appears in the buildMutationHook in the file rtk-query-react.esm.js
useState was imported at the top of that file though
And this import leads to the right place: node_modules/@types/react/index.d.ts
store:
api:
auth endpoint:
user endpoint:
custom hook:
component:
webpack:
babel.config.js:
package.json: