Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

ReactNative - Invalid hook call with useSelector

$
0
0

The following error appear only when I add the "useSelector" row. If this row is commented, everything works fine.

"Invalid hook call, Hooks can only be called inside of the body of afunction component. This could happen for one of the following reasons...."

import React from 'react';import { Text, View } from 'react-native';import { useSelector } from 'react-redux';import { RootState } from './src/store/root-store';const App = () => {  const loginState = useSelector<RootState>(state => state.features.login);  return (<View><Text>Sample</Text></View>  );};export default App;

The project is a React Native app which is part of a yarn workspace composed by other 2 modules: a React web application and a shared TypeScript module.

  • react-native: 0.66.4
  • react-redux: 7.2.6
  • @reduxjs/toolkit: 1.7.1

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>