Feature request: persist route (don't unmount when navigate out)
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- frontend
Research direction
Start by tracing how and mount and clean up elements, then compare that lifecycle with the PersistRoute example in the issue. Determine how a persist prop should behave across navigation, including first visit and later revisits, and add coverage for the expected lifecycle before considering the feature done.
Written by the indexing model from the issue text.
Description
Describe the bug
Not a bug, but no templates for feature requests.
I want to be able to avoid rerendering a previously visited route and the route should keep all the internal state.
"persist?: boolean" prop would be nice
Syntax proposal:
<Routes><Route path="/" persist element={...} /> </Routes>
The way I accomplish it right now:
<Routes>
<Route path="/" element={<Home />} />
<Route path="/stack" />
...
</Routes>
<PersistRoute path="/stack" component={StackTest} />
export const PersistRoute = (p: { path: string; component: FC }) => {
const match = useMatch(() => p.path)
let dispose: () => void | undefined
const render = once(() => {
return createRoot(_dispose => {
dispose = _dispose
return <p.component />
})
})
onCleanup(() => dispose?.())
return <Show when={match()}>{render()}</Show>
}
Your Example Website or App
https://github.com/solidjs/solid-router
Steps to Reproduce the Bug or Issue
None
Expected behavior
When has "persist" prop it should mount the component on first visit and not cleanup on navigate out
Screenshots or Videos
No response
Platform
all
Additional context
No response
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 180
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 19
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from solidjs/solid-router
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
solidjs/solid-router#605 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
solidjs/solid-router#615 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 78/100
solidjs/solid-router#603 · 1 comment ·
-
<A> costs ~6us of server CPU per instance during SSR (20x a plain <a>), mostly mergeProps/splitProps Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
solidjs/solid-router#583 ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
solidjs/solid-router#569 · 3 comments ·
All issues in solidjs/solid-router
Similar issues
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Crush Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md Open
Difficulty 1/5 Under an hour Newbie friendliness 90/100
ElementsProject/cln-application#167 · 1 comment · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Quantco/pnpm-licenses#17 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100