Can we use this library with react-router as well? #4
-
Sorry to open this as an issue, wanted to ask this in a discussion but couldn't find the tab. Since Remix is built on |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
@MAST1999 First of all thank you for the question. I just created discussions for this package and transfered your issue. To answer your question, here is the following information for you to understand how this can work with the react-router and some caveats that I plan to actually fix in the future. How it worksBefore I answer this let me explain how this package works:
Can it be used outside of Remix?Alright, so what does that mean for you and can you use it in non-remix apps? The answer is YES, as long as you're using react-router and react-router-dom with the createBrowserRouter from above you will be able to leverage this package to its full extent. CaveatsThe only issue at the moment is that there is a peer dependency on @remix-run/react. Before I answered this question I tested this package in a Remix app by importing the dependencies directly from react-router-dom instead of that package and it worked fine. I plan to test out this scenario on production code to make sure it works in production Remix apps and if it does the dependency will be converted to react-router-dom and it will not be tied to remix in any way. But for now unfortunately you will probably have to install @remix-run/react along your dependencies to make it work with TL;DRYes but until the next version release you will probably have to install @remix-run/react to make it work |
Beta Was this translation helpful? Give feedback.
-
Support for react router is here! |
Beta Was this translation helpful? Give feedback.
@MAST1999 First of all thank you for the question. I just created discussions for this package and transfered your issue. To answer your question, here is the following information for you to understand how this can work with the react-router and some caveats that I plan to actually fix in the future.
As you might already know react-router introduced their new createBrowserRouter which is probably why you ask this question.
How it works
Before I answer this let me explain how this package works:
@remix-run/react
, mainly the two being useSubmit and useActionData. Both of these are re-exported from react-router-dom, which means that this package is technicall…