Open AlexKMarshall opened 4 years ago
These errors break the build in production mode, so I'll need to fix them now
Looks like some of these dependencies are missing because they were getting into an infinite loop, and useCallback should have been used.
See the description of this issue here https://youtu.be/-Ls48dd-vJE?t=341
Essentially if useEffect relies on a function that is declared within the component, but not within the useEffect callback itself, then useEffect will run every render, as that function will be redeclared every render.
To stop this, the function needs to be wrapped in a useCallback hook.
This is too big of a job for now, there are circular references in the GroupDisplay.js file because the state is not being managed properly.
State is created from props, which shouldn't be done, and derived values are also getting stored in state. It needs a complete rewrite.
This probably shouldn't be done until the server side state is put into a proper library, so parking this.
The useEffect hooks have got lots of issues with missing dependencies.
I expect most of these are used for fetching server-side data, so this probably would be resolved by refactoring to react-query
I think it would be useful to do an audit of all the useState hooks too and see what is actually being stored. Of that, we should see which of them are concerned with purely UI state (contents of forms, modals being open, etc), and which of them are concerned with server side state. The server side state should almost certainly go into react-query. Then with what's left, we should see whether it makes sense to put that into redux or similar, or if it makes sense to just keep that as simple component state (or maybe some context).