Skip to content

Instantly share code, notes, and snippets.

@mehmetyilmaz001
Last active July 17, 2019 11:56
Show Gist options
  • Save mehmetyilmaz001/9d38122732e8be8a99f5de35eb5e76d0 to your computer and use it in GitHub Desktop.
Save mehmetyilmaz001/9d38122732e8be8a99f5de35eb5e76d0 to your computer and use it in GitHub Desktop.
const isInitialMount = useRef(true);
const createQuestionRes = useSelector( s => s.dialog.createQuestionRes);
useEffect(() => {
if(isInitialMount.current){
isInitialMount.current = false;
}else{ // Trigger useEffect only on update (no in did mount)
if(_.has(createQuestionRes, 'hasError') && !createQuestionRes.hasError){
history.push(getMenuItem('QA').path);
}
}
}, [createQuestionRes]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment