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

ESLint is not picking up 'react-hooks/exhaustive-deps' #10545

Closed
ronaldgj opened this issue Feb 12, 2021 · 1 comment
Closed

ESLint is not picking up 'react-hooks/exhaustive-deps' #10545

ronaldgj opened this issue Feb 12, 2021 · 1 comment

Comments

@ronaldgj
Copy link

I use the newest version of create-react-app, but I don't get any errors / warnings when I use a variable or function in a useEffect hook and don't add them to the dependency list.

import { FC, useEffect, useState } from "react";
import Modal from "./lib/modal";

const App: FC = () => {
  const [showModal, setShowModal] = useState(false);

  const handleClose = () => {
    if (showModal) {
      setShowModal(false);
    }
  };

  useEffect(() => {
    
    /* Don't get any warning for 'showModal' */
    if (showModal) {
      console.log("es lint test");
    }
  }, []);

  return (
    <>
      <button onClick={() => setShowModal(true)}>Open Modal</button>
      <Modal show={showModal} onClose={handleClose} />
    </>
  );
};

export default App;

Schermafbeelding 2021-02-12 om 22 18 13

@ronaldgj
Copy link
Author

I'm sorry.. I searched and read the changelog some better and I found out I had to add the ESLINT_NO_DEV_ERRORS=true to the .env file.

Everything works as normal now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant