Conditional fallback routing logic, is this possible?
Hi all, is it possible to create a conditional routing logic?
e.g. route: /custom/edit/:id
if id is null
- query first user's custom object, then redirect to the custom edit page
- if no custom objects are assigned to the user, then redirect to another page
I've been able doing it adding a custom route like
so, it works but it's not the correct way to manage it 🙂 how should I manage this situation?
routes: [
....
{
path: 'custom/edit',
element: <AutoRedirect />,
}
]
and in the AutoRedirect component i've added the logic.
It works BUT I correctly get an error like "Warning: Cannot update a component (BrowserRouter
) while rendering a different component (AutoRedirect
). To locate the bad setState() call inside AutoRedirect
, follow the stack trace as described ..."so, it works but it's not the correct way to manage it 🙂 how should I manage this situation?
1 Reply
extended-salmon•2y ago
Hey @.simoneb,
I think your problem is related to React. Can you edit your
AutoRedirect
component as mentioned here?
https://stackoverflow.com/questions/62336340/cannot-update-a-component-while-rendering-a-different-component-warningStack Overflow
Cannot update a component while rendering a different component war...
I am getting this warning in react:
index.js:1 Warning: Cannot update a component (
ConnectFunction
)
while rendering a different component (Register
). To locate the
bad setState() call inside `