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

app-project: React Hooks error in WorkflowAssignmentModal #6413

Open
eatyourgreens opened this issue Oct 29, 2024 · 3 comments
Open

app-project: React Hooks error in WorkflowAssignmentModal #6413

eatyourgreens opened this issue Oct 29, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@eatyourgreens
Copy link
Contributor

Package

  • app-project

Describe the bug

Spotted while running the tests for the project app. There's a useState hook that appears to run conditionally.

Component > StandardLayout
Warning: React has detected a change in the order of Hooks called by WorkflowAssignmentModal. This will lead to bugs and errors if not fixed. For more information, read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks

   Previous render            Next render
   ------------------------------------------------------
1. useRef                     useRef
2. useDebugValue              useDebugValue
3. useSyncExternalStore       useSyncExternalStore
4. useContext                 useContext
5. useContext                 useContext
6. useCallback                useCallback
7. useState                   useState
8. useRef                     useRef
9. useEffect                  useEffect
10. useRef                    useRef
11. useEffect                 useEffect
12. useEffect                 useEffect
13. useState                  useContext
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    at WorkflowAssignmentModal (/Users/jimodonnell/zooniverse/front-end-monorepo/node_modules/mobx-react-lite/dist/mobxreactlite.cjs.development.js:247:12)
    at main
    at I (/Users/jimodonnell/zooniverse/front-end-monorepo/node_modules/styled-components/dist/styled-components.cjs.js:1:19114)
    at /Users/jimodonnell/zooniverse/front-end-monorepo/node_modules/grommet/components/Box/Box.js:22:24
    at div

To Reproduce

Run the tests for the project app and check the output for StandardLayout. The tests break the rules of hooks, but still pass, so it's easy to miss this error. I only noticed it because it generated a large block of red text in the terminal, and I happened to be watching when the tests ran.

Expected behavior

React hooks have to run in the same order during every render of a component. Breaking the rules of hooks should probably fail the CI tests.

@eatyourgreens eatyourgreens added the bug Something isn't working label Oct 29, 2024
@goplayoutside3
Copy link
Contributor

Trying to replicate this by running yarn test isolated to StandardLayout. Has this warning been resolved by recent changes to the workflow assignment feature?

@eatyourgreens
Copy link
Contributor Author

eatyourgreens commented Nov 25, 2024

It's still showing up in the project app tests, but I don't know how to isolate it.

https://github.com/zooniverse/front-end-monorepo/actions/runs/12019334877/job/33505680307#step:9:676 (around about line 669 in the logs.)

Log output from the project app tests, showing a change in the order of hooks during a render.

@goplayoutside3
Copy link
Contributor

Weird. It looks like the warning is generated by ClassifyPageContainer, and even specifies the test is wrapped by enzyme, which is true of ClassifyPageContainer.spec.js, but isolating those tests and running yarn test:ci does not replicate the warning locally.

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

2 participants