TLDR Web Dev · ARTICLES & TUTORIALS
NEVER CALL NEW DATE() INSIDE YOUR COMPONENTS
Summary from the TLDR Web Dev newsletter
It's good not to call impure functions like `new Date()` inside React components, especially when setting the initial state. Doing so makes testing difficult due to inconsistencies. Instead, it's better to pass the impure function or its result as a prop, which this article shows through code examples.