Skip to content

Commit a282b97

Browse files
authored
fix(solid-router): Should not remount deps when remountDeps does not change (#5693)
1 parent 9b84372 commit a282b97

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

e2e/solid-router/basic-file-based/tests/app.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ test('Should change post navigating back and forth', async ({ page }) => {
273273
await expect(page.getByTestId('post-title')).toContainText('sunt aut facere')
274274
})
275275

276-
test.skip('Should not remount deps when remountDeps does not change ', async ({
276+
test('Should not remount deps when remountDeps does not change ', async ({
277277
page,
278278
}) => {
279279
await page.goto('/notRemountDeps')

packages/solid-router/src/Match.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,19 +222,22 @@ export const MatchInner = (props: { matchId: string }): any => {
222222

223223
const match = () => matchState().match
224224

225+
const componentKey = () => matchState().key ?? matchState().match.id
226+
225227
const out = () => {
226228
const Comp = route().options.component ?? router.options.defaultComponent
227229
if (Comp) {
228-
const key = matchState().key ?? matchState().match.id
229-
return (
230-
<Solid.Show when={key} keyed>
231-
<Comp />
232-
</Solid.Show>
233-
)
230+
return <Comp />
234231
}
235232
return <Outlet />
236233
}
237234

235+
const keyedOut = () => (
236+
<Solid.Show when={componentKey()} keyed>
237+
{(_key) => out()}
238+
</Solid.Show>
239+
)
240+
238241
return (
239242
<Solid.Switch>
240243
<Solid.Match when={match()._displayPending}>
@@ -327,7 +330,9 @@ export const MatchInner = (props: { matchId: string }): any => {
327330
throw match().error
328331
}}
329332
</Solid.Match>
330-
<Solid.Match when={match().status === 'success'}>{out()}</Solid.Match>
333+
<Solid.Match when={match().status === 'success'}>
334+
{keyedOut()}
335+
</Solid.Match>
331336
</Solid.Switch>
332337
)
333338
}

0 commit comments

Comments
 (0)