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

Refactor routes #6766

Closed
Zasa-san opened this issue May 14, 2024 · 1 comment · Fixed by #6767
Closed

Refactor routes #6766

Zasa-san opened this issue May 14, 2024 · 1 comment · Fixed by #6767

Comments

@Zasa-san
Copy link
Collaborator

While developing #6691 we noticed the need to use loader functions from react-router to fetch translations data, without having to rely on our current method that depends on using the redux store. This would also allow us to set our new atom state management in the client on first load, again, without using the redux store.

@Zasa-san
Copy link
Collaborator Author

Zasa-san commented May 20, 2024

We decided to load basic atom store data with a similar technique to what we do for redux. Given the complexities of our server side rendering it is not feasible to have loaders earlier in the component tree (where we set the atom store and construct the routes) to handle data requesting for the first render.

Currently, to construct our routes we need information from settings and the current user if there is one. Without this info we cannot create the routes at entry-client.tsx or entry-server.tsx, the latter already is loading this info. By passing that information through Root.js injected in the window object we can construct our atom store independently from redux and use it to generate the first client side render. We would do the same with translations in the associated issue #6691.

This is not a bad strategy as long as we don’t load a massive amount of data since it pollutes the html. In the future, once we get rid of redux and the legacy routes, we can look for alternatives to communicate this data needed by the client for the first render. Barring a complete revamp of our current SSR and CSR (which is very complex to do with the dependencies that our legacy routes have) I think this is the best approach to set the initial state of the app and construct the routes and atom store.

@konzz @mfacar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant