React Native Expo Context Error

Please provide the following:

  1. SDK Version:
  2. Platforms(iOS/web): ios and web
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

I installed react-router-dom from here because i’m using useParams in the PlayerContext. React Router: Declarative Routing for React.js

I’m getting: Error: Invalid hook call. Hooks can only be called inside of the body of a function component

useEffect has a missing dependency, which can be found in the code sand box attached.

Here’s the file getting the error: react native test - CodeSandbox

any direction would be appreciated!

You are using useContext hook wrong. I’d suggest going through Reactjs docs: https://reactjs.org/docs/hooks-reference.html#usecontext.

Remove the ? and directly pass player.comment as the dependency in the array. The warning will be gone.

i’m not seeing how i’m using it wrong. wrong in the sense of react native? what should i be doing differently?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.