You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When implementing Zustand store actions, we follow these naming conventions:
Use setX for actions that simply change the value of a state
Use updateX for 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 valueif(newIsPrettified===get().isPrettified){return;}set({isPrettified: newIsPrettified});// Performs other actions...setUiState(UI_STATE.FAST_LOADING);// ...}
Background
When implementing Zustand store actions, we follow these naming conventions:
setX
for actions that simply change the value of a stateupdateX
for 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
References
Related PR: #286
The text was updated successfully, but these errors were encountered: