I have a custom collection list view and I noticed that the steps in the header don't update when navigating to the custom list view.
So I searched the code to do it manually and found
useStepNavand the corresponding
setStepNavfunction.
But when using it I get:
TypeError: setStepNav is not a functionMy code in my client component:
const { setStepNav } = useStepNav()
React.useEffect(() => {
const nav: StepNavItem[] = []
nav.push({
label: t('stepList:title'),
url: '/steps',
})
setStepNav(nav)
}, [setStepNav, t])(my collection is also called 'steps' btw, sorry for the confusion)
Is this the wrong way to update the steps in the app-header?
I'm thinking that your custom List view might be outside of the provider that threads this through
Are other hooks working here?
useLocale, useTheme, etc...?
useAuth is working
How could it be outside of the provider though?
This is how I reference the component:
components: {
views: {
list: {
Component: '@/collections/Steps/components/step-list/StepsListComponent#StepsListComponent',
},
},
},Well, it would be outside the provider if custom list views are rendered outside the provider.
If useAuth is working though, then that's not the case
Here's the root provider:
https://github.com/payloadcms/payload/blob/main/packages/ui/src/providers/Root/index.tsx#L54Maybe try using
SetStepNavcomponent instead?
In your view and pass it a list of { label: string, url: string }
I'm not sure why it's giving you trouble here tbh
I have no clue either, but using the
SetStepNavcomponent worked!
Thanks!
- glad it worked for ya! My pleasure
This guy had a same problem as you see
Star
Discord
online
Get dedicated engineering support directly from the Payload team.