Skip to content

Instantly share code, notes, and snippets.

@SaraVieira
Created February 6, 2020 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SaraVieira/837016e9ddd1e94579aee424023baa37 to your computer and use it in GitHub Desktop.
Save SaraVieira/837016e9ddd1e94579aee424023baa37 to your computer and use it in GitHub Desktop.
React.useEffect(() => {
// Make sure our index stays in bounds with max templateInfos
const totalCount = getTotalTemplateCount();
if (focusedTemplateIndex >= totalCount || focusedTemplateIndex < 0) {
safeSetFocusedTemplate(i => i);
}
// We only want this check to happen if templateInfos changes. Only then we
// can get our index out of bounds
// eslint-disable-next-line
}, [templateInfos]);
React.useEffect(() => {
if (initializeProperties) {
initializeProperties({
onCreateModuleClick,
onCreateDirectoryClick,
onUploadFileClick,
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(() => {
if (props.value) {
updateValues(props.value);
}
// eslint-disable-next-line
}, []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment