Triggering all loaders for navigate(/some/path)
#13551
Unanswered
ahmed-revv
asked this question in
Q&A
Replies: 1 comment
-
I guess we should manipulate the header using react state + useState for the active item. But, that becomes bit extra code and I was wondering if there is a better remix/react router way for this. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Overview
I am using react route v7 as framework mode + SPA (
ssr: false
). My project has below layout component (layout.tsx):Question
Assuming I am on the route
/somepath/p1
and the sidebar dropdown has[p1, p2, p3]
and p1 is active. When user clicks on p2, I want to navigate to/somepath/p2
and the sidebar should have the current_item asp2
. Currently, I have implemented the below action inlayout.tsx
just to trigger the loaders and pass current item to the sidebar from layout loader. Note that/somepath/:id
has its corresponding clientLoader to get the data.I have used clientAction explicitly here since it triggers the loader in layout route (and fetch the latest data and active state) as well. I tried doing just navigate to
/somepaht/p2
but that doesn't trigger layout loader (which I think is expected) and hence sidebar data and active item is not updated to reflect the current state.But, calling an
action
without any mutation seems bit odd. Is there any better solution for the above use case ? Could someone please help with this ?Beta Was this translation helpful? Give feedback.
All reactions