On page load I need to perform some logic based on the URL and then dispatch a Redux action. This code works fine but gives me a TypeScript error:
React.useEffect(() => {
const { search } = window.location;
const removeFirstQuestionMark = search.slice(1);
if (!removeFirstQuestionMark) {
return null;
}
// more logic
reduxAction({
foo: 'bar'
});
return null;
}, []);
error TS2345: Argument of type '() => null | undefined' is not assignable to parameter of type 'EffectCallback'. Type 'null | undefined' is not assignable to type 'void | (() => void | undefined)'. Type 'null' is not assignable to type 'void | (() => void | undefined)'.
14 React.useEffect(() => {