Skip to content

Document Zustand store action naming conventions in dev docs #289

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

Open
coderabbitai bot opened this issue May 21, 2025 · 0 comments
Open

Document Zustand store action naming conventions in dev docs #289

coderabbitai bot opened this issue May 21, 2025 · 0 comments

Comments

@coderabbitai
Copy link

coderabbitai bot commented May 21, 2025

Background

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 value
  if (newIsPrettified === get().isPrettified) {
    return;
  }
  set({isPrettified: newIsPrettified});
  
  // Performs other actions...
  setUiState(UI_STATE.FAST_LOADING);
  // ...
}

References

Related PR: #286

@junhaoliao junhaoliao removed their assignment May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant