reapp / reapp-routes

Simple route DSL
MIT License
34 stars 13 forks source link

What's the point of using context? #3

Closed lazywei closed 9 years ago

lazywei commented 9 years ago

Hi,

I notice that in the latest version of reapp-routes, we need to use this.context.router.transitionTo instead of this.transitionTo. I'm wondering why we should do this. What's the cons of using the old way to access the react-router's transitionTo?

Thanks.

natew commented 9 years ago

You'd need to create a mixin to simplify that and mix it into your routes like previously. I think the only difference is now react-router won't be supplying that mixin.

I'm thinking about it. Reapp is in alpha, but this release especially is shaky because both react-router and our theme engine moved to React 0.13 and new ways of using context.

It almost feels like React is asking for Decorators now. I use reapp-component for this. The hacker-news-app uses them if you want a demo. Basically you could mixin the router mixin everywhere.

I'm thinking about better ways to handle all this. I want to make reapp simpler than it is now, but still flexible. I think it's almost to the point where we can just say "react-router has won" and commit to it and that would open up some stuff to be easier.

natew commented 9 years ago

I will say personally, I don't mind the this.context.router syntax. It's more verbose, but it's also less magical than before. But I understand where you're coming from.

lazywei commented 9 years ago

Got it. Thanks for explanation.

I will say personally, I don't mind the this.context.router syntax. It's more verbose, but it's also less magical than before.

I definitely agree with you on this! Honestly, this.transitionTo made me confused for a while that I don't know where it comes from until I trace the source code. Now I understand your designation, and I totally agree with your direction.

Good work! Thanks! :+1: