Too many re-renders
When I render this component that is a client component of a dashboard slug, it breaks the entire page and re-renders so many times that it force stops. I store the id of a project inside of the url like this
I want to display the route of the url (dashboard, notes, settings) in the DashNav. example in image.
This is how I do that now, but it completely breaks my entire page. Is there a better way to do this?
Solution:Jump to solution
Think of react components as running top to bottom, and every time you call 'setState', it tells react to put in a request for the component to be re-rendered top to bottom. In your react, every render will call a set state, and trigger a rerender
2 Replies
Solution
Think of react components as running top to bottom, and every time you call 'setState', it tells react to put in a request for the component to be re-rendered top to bottom. In your react, every render will call a set state, and trigger a rerender
The API your looking for in this case is
usePathname
, or you could use a more generic useSelectedLayoutSegment