Skip to content
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

[bug]: SidebarProvider - Writing to a variable defined outside a component or hook is not allowed. Consider using an effect eslint(react-compiler/react-compiler) #6912

Open
2 tasks done
MGSimard opened this issue Mar 12, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@MGSimard
Copy link

Describe the bug

While using React Compiler and its recommended ESLint settings, we find this violation within the SidebarProvider component:

Writing to a variable defined outside a component or hook is not allowed. Consider using an effect eslint(react-compiler/react-compiler)

@ document

// This sets the cookie to keep the sidebar state.
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;

It probably still works fine, but adhering to best React standards should be a priority.

Affected component/components

sidebar.tsx / SidebarProvider

How to reproduce

  1. Enable React Compiler + ESLint
  2. Go to SidebarProvider in sidebar.tsx, line 73 @ document

Codesandbox/StackBlitz link

No response

Logs

System Info

N/A

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@MGSimard MGSimard added the bug Something isn't working label Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant