[ad_1]
it’s giving me this error in the console Invalid hook call. Hooks can only be called inside of the body of a function component.
-I’ve tried writing npm link -even checked if I have 2 reacts, but that is not the case -My react and react-dom version is also the same
yet this error persists
this is my code in CryptoContext.js which I’m using as my context api file
import React, { useContext, useEffect } from ‘react’; import { createContext } from ‘react’; import { useState } from ‘react’; const Crypto = createContext(); const CryproContent = ({ children }) => { const [currency, setCurrency] = useState(“INR”); const [symbol, setSymbol] = useState(“”); useEffect(() => { if (currency === “INR”) setSymbol(“”); else if (currency === “USD”) setSymbol(“$”); }, [currency]); return (
{children}
) } export default CryproContent; export const CryptoState = () => { return useContext(Crypto); }
|
Sources 2/ https://stackoverflow.com/questions/73595516/i-was-creating-a-crypto-price-tracker-website-using-react-js-and-hooks-i-guess The mention sources can contact us to remove/changing this article |
[ad_2]