-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
Background
When implementing Zustand store actions, we follow these naming conventions:
- Use
setXfor actions that simply change the value of a state - Use
updateXfor actions that do more than simply changing a value (e.g., perform additional logic, make API calls, update multiple states)
Task
Add this naming convention to the development documentation to ensure consistent implementation across the codebase.
Example
// Example of a simple setter (use 'set' prefix)
setPageNum: (newPageNum: number) => {
set({pageNum: newPageNum});
}
// Example of a complex action (use 'update' prefix)
updateIsPrettified: (newIsPrettified: boolean) => {
// Has additional logic beyond just setting the value
if (newIsPrettified === get().isPrettified) {
return;
}
set({isPrettified: newIsPrettified});
// Performs other actions...
setUiState(UI_STATE.FAST_LOADING);
// ...
}References
Related PR: #286
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels