4 ms·
I'm with you. First when I thought of building a SPA application with React on my side project; I tried React-Router, the API was not that easy to grasp at firs
by antoaravinth 10y ago
I'm with you. First when I thought of building a SPA application with React on my side project; I tried React-Router, the API was not that easy to grasp at first for me.
Then I have build my own router with `popstate` event and I'm quite happy with it. All the navigation history is pushed to redux. It turns out that it works really well for my needs and application.
- chrisabrams 10y agoHave a link to your router?
- antoaravinth 10y agoSorry, no. However, you can find the same pattern being used in the sound-redux project-https://github.com/andrewngu/sound-redux https://github.com/andrewngu/sound-redux
- wesleytodd 10y agoWe did something similar that uses the Express router: https://github.com/wesleytodd/nighthawk https://github.com/wesleytodd/nighthawk The one thing we didn't do was layer on top of a flux solution. Seemed more future proof to not tie to anything other than a routing style. If you wanted to do that with our solution it would be as simple as writing an action to do the url change.
- tothepixel 10y agoI built a React app for a large Ecom site recently using the same strategy. It handles all URL updates with the History API, and simply AJAX loads the same URL with a query param to hydrate the app with JSON. Works really simply, and doesn't require Redux, Flux, or React Router.