Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm test returns React Hook useEffect has a missing dependency: 'item' #79

Open
simonovskifilip opened this issue May 18, 2021 · 0 comments
Labels
bug Something isn't working frontend

Comments

@simonovskifilip
Copy link

When starting the test function for the frontend it returns an error saying:

./src/templates/dataset/index.jsx
  Line 35:6:  React Hook useEffect has a missing dependency: 'item'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

The error could be solved by extending the code in ./src/templates/dataset/index.jsx with }, [id, state, item]);.

So the function looks as follows:

  useEffect(() => {
    if (window !== undefined) {
      checkForWindow(true);
    }
    async function getItem() {
      const { data } = await axios.get(`${process.env.REACT_APP_ROOT_URL}/metastore/schemas/dataset/items/${id}?show-reference-ids`);
      setItem(data);
      console.log("item: ", item);
    }
    if (!state || !state.dataset) {
      getItem();
    }
  }, [id, state, item]);

This may fix the error message but still the page will not be created.

@simonovskifilip simonovskifilip added bug Something isn't working frontend labels May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working frontend
Projects
None yet
Development

No branches or pull requests

1 participant