-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Mantine UI Series] useListState & useSetState #16
Comments
Managing mutable state variables in React.
|
useListStateDetailed documentations:
By utilizing the Under the hood, |
useSetStateWhen working with Object type React state variables, we face the same issue like working with Array type React state variables, the grammar to update part of the variable is cumbersome. For example, for the following code: setSensor({
displayName: 'newSensor',
}); the sensor data will be erased and only the useSetState resolves above pain by wrapping the exposed setState with state updater function. Let's take a look on the source code |
Overview
This article discusses two hooks supported by
mantine/hooks
:useListState
useSetState
We will also explore the general pattern used in their source code ( as well as that of some other hooks , such as
useDisclosure
).Besides, this article also covers the suggestions from official React documentations about how to handle mutable values, such as object, array, in React state management.
The text was updated successfully, but these errors were encountered: