T
TanStack6mo ago
equal-aqua

Doc example improvement

Hey, I was looking at some tanstack router examples and was wondering if const [filterDraft, setFilterDraft] = React.useState(filterBy ?? '') was a bad practice, why do we duplicate the url state into a useState in this case ? https://tanstack.com/router/latest/docs/framework/react/examples/kitchen-sink-file-based?path=examples%2Freact%2Fkitchen-sink-file-based%2Fsrc%2Froutes%2Fdashboard.users.route.tsx Can't we do something like this instead:
onChange={(e) =>
navigate({
search: (old) => {
return {
...old,
usersView: {
...old.usersView,
filterBy: e.target.value || undefined,
},
};
},
replace: true,
})
}
onChange={(e) =>
navigate({
search: (old) => {
return {
...old,
usersView: {
...old.usersView,
filterBy: e.target.value || undefined,
},
};
},
replace: true,
})
}
React TanStack Router Kitchen Sink File Based Example | TanStack Ro...
An example showing how to implement Kitchen Sink File Based in React using TanStack Router.
1 Reply
wise-white
wise-white6mo ago
probably true. want to create a PR for this?

Did you find this page helpful?