DEV Community

axtk
axtk

Posted on

Yet another router and a state management lib

I totally understand why people keep looking for new approaches to routing and state management in React. Apparently, these tasks can be solved in multiple ways focusing on different aspects, which is fine. But among the several common solutions (and several less common ones), I can't find a direct approach following the common patterns, which leaves me with the questions at the basickest level:

Can routing be as simple as regular conditional rendering, which route-based rendering essentially is?

Can route-based rendering be the same with components and prop values? Again, like conditional rendering. Unlike having a separate file, a config, or a <Route> component to render an app component based on a route, but going for a route matching hook to render a prop value based on the route.

Do we really need a custom <Link to> component API, while there's an all-familiar HTML <a href> API?

Is it inevitable that local and shared state being conceptually similar things are handled so differently, requiring significant refactors to migrate from one to the other even with the slimmest state management libs?

With these questions having lingered for a while, I came up with a couple of small packages for React apps in an attempt to address these questions and to make a case for the direct approach:

t8.js.org

Along the way I came up with a router for vanilla TS/JS, too.

Let me know what you think of this.

Top comments (0)