Closed chaaya closed 6 years ago
@chaaya, as far as I can tell, this change would make the the router dependent on React. The basic design principle we have been following is to completely decouple the router from the presentation layer. It is a simple state-machine that should be able to run without a front-end. Please let me know your thoughts. If you agree, please close this PR.
@nareshbhatia I kind of agree with you, yes you could still use the core without react and write your own view layer that observers state changes and renders the correct view. The reason I kind of agree with you is that the Github info says:
My guess is that 98% people using this is using it in conjunction with React.
One idea is to make two repos, mobx-state-router-core and mobx-state-router-react in that case so that people can choose if they just want the core and write their own render layer or use the out-of-the-box solution with React. What do you think of that?
@chaaya, while I agree that mobx-state-router is mostly used with React, I still think we should not mix presentation and state in the router itself. You might want to read Michel's article How to decouple state and UI to reinforce this idea. If you still like to continue with your approach, please feel free to maintain a fork.
I am going to close this PR, but be assured that I am always open to new ideas, so please keep them coming.
Instead of passing a viewMap, this change makes it more like react-router where you pass the component to render as property in the route configuration.
The change includes a new computed property in the routerStore, activeView, which relies on the internal viewMap thats being created in the constructor that maps the component with the route name.