Skip to content

Instantly share code, notes, and snippets.

@treyhuffine
Last active March 5, 2019 00:56
Show Gist options
  • Select an option

  • Save treyhuffine/40628c69cc18bdfeedd6d65373249d15 to your computer and use it in GitHub Desktop.

Select an option

Save treyhuffine/40628c69cc18bdfeedd6d65373249d15 to your computer and use it in GitHub Desktop.
function DelayedEffect(props: { timerMs: number }) {
const { timerMs } = props;
// ** BAD! ** setTimeout implicitly returns a number because the arrow function body isn't wrapped in curly braces
useEffect(() => setTimeout(() => {/* do stuff */}, timerMs), [timerMs])
// **
return null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment