You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I'm new to solid and migrating from React. I'm very familiar with React-Router and, lately, using it with config-based-like syntax as seen here. The thing is, when I'm trying to add undefined route handling, I'm getting some errors that I don't get when using JSX-like routing. Here is the comparison
imports....
constHome=lazy(()=>import('./pages/Home'));functionApp(){
....return(<Routes><Routepath="/"element={<Home/>}/><Routepath="/search"element={<p>Search</p>}/><Routepath="*"element={<p>Page Not found</p>}/></Routes>)}
With this example, when accessing /randomUrl i get the Page not found text, so it's working. But when using config-based routing, it doesn't.
constHome=lazy(()=>import('./pages/Home'));constroutes=[{path: '/',component: <Home/>,},{path: '*',element: <p> Page not found </p>,},];functionRoutes(){constR=useRoutes(routes);return(<><R/></>);}
When using this router, I go to an empty page. Any ideas?
Thanks!
PD: Also, whats the difference between component and element in the <Route /> component?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi. I'm new to solid and migrating from React. I'm very familiar with React-Router and, lately, using it with config-based-like syntax as seen here. The thing is, when I'm trying to add undefined route handling, I'm getting some errors that I don't get when using JSX-like routing. Here is the comparison
With this example, when accessing
/randomUrl
i get thePage not found
text, so it's working. But when using config-based routing, it doesn't.When using this router, I go to an empty page. Any ideas?
Thanks!
PD: Also, whats the difference between
component
andelement
in the<Route />
component?Beta Was this translation helpful? Give feedback.
All reactions