score:0

If you verified that react >= 16.8.3 and react-redux >= 7.1.1 try the solution below. The workaround for me was to install metro package version 0.56.0 .

Via npm: npm install metro@0.56.0

Via yarn yarn add metro@0.56.0

score:0

My problem was importing useSelector from react...

import React, { useSelector } from 'react';

, but it actually is:

import React from 'react';
import { useSelector } from 'react-redux';

score:1

useSelector() hook only takes functions as input, so to resolve your issue you have to make a function that will handle your logic and then call it in useSelector. Here is an example:

This is an es6 function

    const getMeals(state) => {
return state.meals.filteredMeals;
}

And then pass your function into useSelector like this:

const availableMeals = useSelector(getMeals(myState));

You can put this function(getMeals) in your current component or even put it in your reducer.

score:2

I upgraded react-redux version from ^5.1.1 to ^7.1.1 in package.json file.

This caused an upstream dependency error when I run;

npm install

I fixed that by upgrading react version from 16.8.0 to 16.8.3 in package.json file.

After that, I was able to install both dependencies and stopped receiving error below;

TypeError: TypeError: (0, _reactRedux.useSelector) is not a function

Related Query

More Query from same tag