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

chore: react 18 fixes #124

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

chore: react 18 fixes #124

wants to merge 2 commits into from

Conversation

janrtvld
Copy link
Contributor

@janrtvld janrtvld commented Oct 19, 2022

React 18 has some new strict mode functionalities that made components rerender. I think its explained under React v18 unmounting and remounting architecture in this post and this stackoverflow question.

What happens is components are loaded twice, which in our case made tests fail as it made 2 api calls for creating an invitation, while the first one is intercepted but overwritten by the second one (which the application uses).

I think this is the issue, because when i remove the StrictMode everything works fine.

Signed-off-by: Jan [email protected]

@janrtvld janrtvld changed the title feat: react 18 fixes chore: react 18 fixes Oct 19, 2022
@janrtvld
Copy link
Contributor Author

I will try to find a fix as removing StrictMode might result into other issues.

@TimoGlastra
Copy link
Member

Yes have seen a lot of issues with this. There's some guidance in the new docs on this: https://beta.reactjs.org/learn/synchronizing-with-effects#how-to-handle-the-effect-firing-twice-in-development

@Tommylans
Copy link
Member

@janrtvld @TimoGlastra

I think it's really hard to prevent this. It also has to do with how we made the app we want things to happen when you enter a specific page. Everything is also dependent on each other and some things can only happen once. This is quite rare in web applications because normally in most business applications almost everything is just fetching information and executing a action based on a button click.

So the possible options that we have are:

@TimoGlastra
Copy link
Member

Hmm what is the option you prefer/suggest?

@janrtvld
Copy link
Contributor Author

Only using it in the test will only solve halve of the problem, because that would still result in issues when your developing.

My preference would be to refactor the useEffects to the new React 18 way. The solution itself is pretty straightforward, it's just a tedious job.

@Tommylans
Copy link
Member

Yeah with strictmode you will get all the proof and issued credentials twice... So I think then updating all the useEffects that will create something or changes a mandatory state will need a refactor.

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

Successfully merging this pull request may close these issues.

3 participants