A babel plugin to automagically add the deps array to your hook calls.
function App() {
const [state, setState] = useState(0);
const toDisplay = useMemo(() => {
return state;
});
return <></>;
}
function App() {
const [state, setState] = useState(0);
const toDisplay = useMemo(() => {
return state;
}, [state]);
return <></>;
}
function App() {
const [state, setState] = useState(0);
const toDisplay = useMemo(() => {
return state;
}, [state]);
return <></>;
}
function App() {
const [state, setState] = useState(0);
const toDisplay = useMemo(() => {
return state;
}, [state]);
return <></>;
}
function App() {
const [state, setState] = useState(0);
const toDisplay = useMemo(() => {
return state;
}, undefined);
return <></>;
}
function App() {
const [state, setState] = useState(0);
const toDisplay = useMemo(() => {
return state;
});
return <></>;
}
Using NPM:
npm install --save-dev babel-plugin-react-no-hook-dependency
Using yarn:
yarn add babel-plugin-react-no-hook-dependency --dev