Update useCallback.md - rename ShoppingForm to ShippingForm (#5656)

This commit is contained in:
skyhawk14
2023-03-18 04:59:55 +05:30
committed by GitHub
parent 9f929d3195
commit 657cd40016

View File

@@ -385,9 +385,9 @@ button[type="button"] {
#### Always re-rendering a component {/*always-re-rendering-a-component*/}
In this example, the `ShoppingForm` implementation is also **artificially slowed down** so that you can see what happens when some React component you're rendering is genuinely slow. Try incrementing the counter and toggling the theme.
In this example, the `ShippingForm` implementation is also **artificially slowed down** so that you can see what happens when some React component you're rendering is genuinely slow. Try incrementing the counter and toggling the theme.
Unlike in the previous example, toggling the theme is also slow now! This is because **there is no `useCallback` call in this version,** so `handleSubmit` is always a new function, and the slowed down `ShoppingForm` component can't skip re-rendering.
Unlike in the previous example, toggling the theme is also slow now! This is because **there is no `useCallback` call in this version,** so `handleSubmit` is always a new function, and the slowed down `ShippingForm` component can't skip re-rendering.
<Sandpack>