Skip to content
Advertisement

React-toolkit Cannot read properties of undefined (reading ‘type’) error

I’m learning redux-toolkit and I wrote sample code, but when using useDisptach method I get “Cannot read properties of undefined (reading ‘type’)” error. What do you think is the reason for this? I am sharing the code below:

my index.js file:

JavaScript

my device.js file:

JavaScript

my store.js file :

JavaScript

Advertisement

Answer

I found where I made a mistake. The import on line 5 in the index.js file should have been like this: import { detectDevice } from “../redux/device”;

Advertisement