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

Rerender stopped working on version 5.1.0 #369

Closed
LuisaAPF opened this issue Apr 29, 2024 · 3 comments
Closed

Rerender stopped working on version 5.1.0 #369

LuisaAPF opened this issue Apr 29, 2024 · 3 comments

Comments

@LuisaAPF
Copy link

LuisaAPF commented Apr 29, 2024

Tests that use rerender started failing after upgrading from 4.1.0 to 5.1.0. I understand the function behaviour changed recently, but this is not working for me:

it('should show MyComponent when show = true', async () => {
    const { rerender } = render(MyComponent, {
      props: {show: true}
    })

    expect(screen.queryByTestId('my_component')).toBeInTheDocument()

    await rerender({props: {show: false}})

    expect(screen.queryByTestId('my_component')).not.toBeInTheDocument()
})
@mcous
Copy link
Collaborator

mcous commented Apr 29, 2024

Apologies, the docs PR detailing this change has not yet merged was only just merged today.

You now simply pass props to rerender directly. You should be seeing a warning log to this effect.

- await rerender({props: {show: false}})
+ await rerender({show: false})

@LuisaAPF
Copy link
Author

Thanks for your reply @mcous. I think I figured out the reason the tests broke. It wasn't because of the syntax (by the way, I didn't see any warnings, not sure if Vitest is suppressing them). It was because I was not using a reactive variable to hide my component, but instead a regular variable that depends on the prop and which was being assigned on mount.

@mcous
Copy link
Collaborator

mcous commented Apr 30, 2024

Gotcha; that makes sense! rerender in v4 destroyed and remounted the component, which would prevent you from seeing those sorts of reactivity bugs. That's why it was changed!

@mcous mcous closed this as not planned Won't fix, can't repro, duplicate, stale Apr 30, 2024
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

No branches or pull requests

2 participants