Component does not reset
Unanswered
Carpenter ant posted this in #help-forum
Carpenter antOP
Help please, I have a page (app/ChannelsPage)
And there is a component ChannelsComponent, how to make it so that the component does not reset its state when changing channelsSlug
const ChannelsPage = ({ params }: { params: { channelsSlug: string[] } }) => {
return <ChannelsComponent channelsSlug={params.channelsSlug} />;
};And there is a component ChannelsComponent, how to make it so that the component does not reset its state when changing channelsSlug
2 Replies
@Carpenter ant Help please, I have a page (app/ChannelsPage)
`const ChannelsPage = ({ params }: { params: { channelsSlug: string[] } }) => {
return <ChannelsComponent channelsSlug={params.channelsSlug} />;
};`
And there is a component ChannelsComponent, how to make it so that the component does not reset its state when changing channelsSlug
put <ChannelsComponent> in a common layout, convert to client component, then get the params from
useParams() client component hookor put the data in a top-level context, preferably managed by a state management like RQ because, the state will always be lost if you do hard navigation