Repository navigation
feat(react-router): add useCanGoBack - #3017
Conversation
|
View your CI Pipeline Execution ↗ for commit d471ca4.
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/arktype-adapter
@tanstack/create-router
@tanstack/eslint-plugin-router
@tanstack/history
@tanstack/react-cross-context
@tanstack/create-start
@tanstack/react-router
@tanstack/react-router-with-query
@tanstack/router-cli
@tanstack/router-devtools
@tanstack/router-generator
@tanstack/router-plugin
@tanstack/router-vite-plugin
@tanstack/start
@tanstack/start-vite-plugin
@tanstack/valibot-adapter
@tanstack/virtual-file-routes
@tanstack/zod-adapter
commit: |
| // This is a fallback for when updating the router and there are history entries without index | ||
| // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| const currentIndex = location.state.index ?? 0 | ||
| state = assignKey({ ...state, index: currentIndex + 1 }) |
There was a problem hiding this comment.
can we put this logic into assigKey()?
| // This is a fallback for when updating the router and there are history entries without index | ||
| // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| const currentIndex = location.state.index ?? 0 | ||
| state = assignKey({ ...state, index: currentIndex }) |
There was a problem hiding this comment.
same as above, can we put this logic into assigKey()?
| entries[index] = path | ||
| }, | ||
| back: () => { | ||
| console.log('back', index) |
There was a problem hiding this comment.
shouldn't this be index?: number as the index is not set for the initial entry?
also, i think we should use a more ... obscure name to not collide with user data
e.g. __TSR_index ?
There was a problem hiding this comment.
It's always available after we run through parseHref, this is because, if the route has no state (should be valid only for initial route), we default it to { index: 0 }. About the naming, sure, but by that logic, shouldn't the key also be renamed?
There was a problem hiding this comment.
ideally, yes. but the key has been there since the beginning, but adding an index now could introduce a breaking change
There was a problem hiding this comment.
| describe('history: History gives correct notifcations and state', () => { | |
| describe('history: History gives correct notifications and state', () => { |
There was a problem hiding this comment.
we should run the same test for all history types
There was a problem hiding this comment.
can you please always use { } even for one liners?
There was a problem hiding this comment.
so can we remove it?
…nd has index in state
|
Small question. Is this new Cause after updating my router version I started getting this error: Should I manually assign it with some value (like |
|
no this is meant to be automatically set @ferretwithaberet we need to make it optional |
|
After updating I'm getting this error all over my code too. |
|
Hi, sorry to bother. Just wanted to say I love you guys. Your working is amazing. |
fixes #2983