react.dev
react.dev copied to clipboard
[Suggestion]: Add some elaboration to the docs for TypeScript DOM events and Pure Functions
Summary
The Section on DOM events in the page Using TypeScript, mentions extracting functions, this can be elaborated further to include the case where we do get the types i.e. inline methods.
~~The section on Pure Functions contain a example of Teacups and guests, the global let guests variable should be incremented by 1, but is incremented by 2. Since, React is running in StrictMode for development, this might be confusing for newbies. Found here: https://react.dev/learn/keeping-components-pure#side-effects-unintended-consequences~~
Edit: The deep dive for this chapter contains the explanation.
Page
https://react.dev/learn/keeping-components-pure
Details
Add another small example where it shows that we do get types when using inline methods, to make it more clear.
~~Either turn off Strict mode for this example OR explain why we are getting 2, 4, 6 instead of the expected 1, 2, 3 because of React.StrictMode.~~