ExceptionsManager.js:179 Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
- You might have mismatching versions of React and the renderer (such as React DOM)
- You might be breaking the Rules of Hooks
- You might have more than one copy of React in the same app
Getting this error in Playbutton component
Playbutton.js
import { useNavigation } from "@react-navigation/native";
import React, { useEffect, useState, useRef } from "react";
import { useSelector, useDispatch } from "react-redux";
import {
View,
Button,
StyleSheet,
Image,
TouchableOpacity,
Dimensions,
NativeModules,
} from "react-native";
var deviceHeight = Dimensions.get("window").height;
var deviceWidth = Dimensions.get("window").width;
import useAppleFunction from "../CustomHooks/useAppleFunction";
const PlayButton = () => {
useEffect(() => {
useAppleFunction();
}, []);
}
and here is the custom hook useApplefunction.js
import { StyleSheet, Text, View } from "react-native";
import React, { useEffect } from "react";
import { useSelector } from "react-redux";
const useAppleFunction = () => {
const Playlist = useSelector((state) => state);
console.log("reduxcheck=",Playlist);
useEffect(() => {
runtimer();
}, []);
const runtimer = () => {
console.log("reduxcheck=1",Playlist);
};
};
export default useAppleFunction;
const styles = StyleSheet.create({});