Skip to content

Instantly share code, notes, and snippets.

@zzdjk6
Last active May 17, 2020 06:49
Show Gist options
  • Save zzdjk6/09ce33e393bba9a895adbb721710e685 to your computer and use it in GitHub Desktop.
Save zzdjk6/09ce33e393bba9a895adbb721710e685 to your computer and use it in GitHub Desktop.
React Hooks Invalid #EarlyReturn
const MyComponent: React.FC = () => {
const data1 = useData1();
if (!data1) {
return null;
}
const data2 = useData2(data1);
if (!data2) {
return null;
}
const result = React.useMemo(() => aggregateData(data1, data2), [
data1,
data2,
]);
if (!result) {
return null;
}
return <ResultDisplay result={result} />;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment