You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've never been this excited about React Router. Like you, we've
49
-
learned a lot about React since we first picked it up. We built a Router
50
-
the best we knew how along the way. What we've learned most is that we
51
-
love React because of its **declarative composability**.
48
+
We've never been this excited about React Router. Like you, we've learned a lot about React since we first picked it up. We built a Router the best we knew how along the way. What we've learned most is that we love React because of its **declarative composability**.
52
49
53
-
As we looked at the router, it didn't work that way because of the
54
-
static route configuration. You couldn't even wrap a Route!
50
+
As we looked at the router, it didn't work that way because of the static route configuration. You couldn't even wrap a Route!
For apps to participate in rendering of route components, we had to
62
-
create APIs we were never actually comfortable with, like `<Router
63
-
createElement render>` and `createRouterMiddleware`. We took
64
-
`createElement` away from you and had to give it back!
57
+
For apps to participate in rendering of route components, we had to create APIs we were never actually comfortable with, like `<Router createElement render>` and `createRouterMiddleware`. We took `createElement` away from you and had to give it back!
65
58
66
-
We had to recreate the lifecycle hooks with `onEnter`, `onLeave`, and
67
-
`onChange`. React already has `componentWillMount`,
59
+
We had to recreate the lifecycle hooks with `onEnter`, `onLeave`, and `onChange`. React already has `componentWillMount`,
68
60
`componentWillReceiveProps` and `componentWillUnmount`.
69
61
70
-
Route configs described your view hierarchy. Turns out, React components
71
-
already describe view hierarchy.
62
+
Route configs described your view hierarchy. Turns out, React components already describe view hierarchy.
72
63
73
-
To code-split, we had to introduce `getComponent` and `getChildRoutes`.
74
-
Hot module replacement libs had to do specific hacks for routes to work.
75
-
The list goes on and on.
64
+
To code-split, we had to introduce `getComponent` and `getChildRoutes`. Hot module replacement libs had to do specific hacks for routes to work. The list goes on and on.
76
65
77
-
React Router was not a React router, it was a routing framework for
78
-
React. An accidental framework with APIs that were not only redundant
79
-
with React, but incredibly difficult to build an ecosystem around.
66
+
React Router was not a React router, it was a routing framework for React. An accidental framework with APIs that were not only redundant with React, but incredibly difficult to build an ecosystem around.
80
67
81
-
What did we do? We took everything we've learned and love about React
82
-
(and we're still learning!) and applied it to routing. It started with
83
-
the quest to actually render a `<Route>` (we used to just strip their
84
-
props). It ended with removing the idea of routes completely (surprised
85
-
us too) and a completely component based API, which actually means no
86
-
API at all.
68
+
What did we do? We took everything we've learned and love about React (and we're still learning!) and applied it to routing. It started with the quest to actually render a `<Route>` (we used to just strip their props). It ended with removing the idea of routes completely (surprised us too) and a completely component based API, which actually means no API at all.
87
69
88
-
You control routing by rendering components and passing props. Finally,
89
-
we have a solid base for us and others to build an ecosystem on top of.
70
+
You control routing by rendering components and passing props. Finally, we have a solid base for us and others to build an ecosystem on top of.
90
71
91
72
In other words, it's Just React™ and you're going to love it.
92
73
93
74
### How long until another huge API overhaul?
94
75
95
-
We know things have been rocky for a lot of people regarding the router
96
-
API, to the point that the router has a reputation for huge API
97
-
overhauls.
76
+
We know things have been rocky for a lot of people regarding the router API, to the point that the router has a reputation for huge API overhauls.
98
77
99
-
We went back and audited the changes to the major versions. From 0.13
100
-
to 1.0 there were huge, backwards incompatible, changes. From 1.0 to 2.0
101
-
there were some subtle, but fully backwards compatible changes, and 3.0
102
-
will be 2.0 but without any deprecation warnings.
78
+
We went back and audited the changes to the major versions. From 0.13 to 1.0 there were huge, backwards incompatible, changes. From 1.0 to 2.0 there were some subtle, but fully backwards compatible changes, and 3.0 will be 2.0 but without any deprecation warnings.
103
79
104
-
It has been 18 months since the release of 1.0. So, if you've kept
105
-
up with only the non-beta releases, you've only had to update your code
106
-
once in a year and a half.
80
+
It has been 18 months since the release of 1.0. So, if you've kept up with only the non-beta releases, you've only had to update your code once in a year and a half.
107
81
108
-
Our previous API was fighting against React. With v4, our only API is
109
-
components that receive props, so, it's hard to imagine a big change
110
-
again. Now that we're embracing (not fighting) React's declarative
111
-
composability, we think this API will last as long as React itself,
112
-
because that's all it is.
82
+
Our previous API was fighting against React. With v4, our only API is components that receive props, so, it's hard to imagine a big change again. Now that we're embracing (not fighting) React's declarative composability, we think this API will last as long as React itself, because that's all it is.
113
83
114
-
We're excited to create and encourage building an ecosystem of addons to
115
-
this stable base. In the words of Cheng Lou, we've become more powerful
116
-
(https://www.youtube.com/watch?v=mVVNJKv9esE).
84
+
We're excited to create and encourage building an ecosystem of addons to this stable base. In the words of Cheng Lou, we've become more powerful (https://www.youtube.com/watch?v=mVVNJKv9esE).
117
85
118
86
### Why did you get rid of feature [x]?
119
87
120
-
We've been pulled a lot of directions with bleeding edge use-cases that
121
-
nobody really has generic answers for: server rendering, code-splitting
122
-
while avoiding waterfalls, anticipating streamed server rendering, loading
123
-
data before rendering anything, etc. We unconsciously tried to solve this
124
-
stuff when all we really want to be doing is keeping rendered UI in sync
88
+
We've been pulled a lot of directions with bleeding edge use-cases that nobody really has generic answers for: server rendering, code-splitting while avoiding waterfalls, anticipating streamed server rendering, loading data before rendering anything, etc. We unconsciously tried to solve this stuff when all we really want to be doing is keeping rendered UI in sync
125
89
with the url. That's our scope of responsibility.
126
90
127
-
By using components as our only API, features we had that are important
128
-
to you can be implemented on top of these components.
91
+
By using components as our only API, features we had that are important to you can be implemented on top of these components.
129
92
130
93
We will be creating some addons and hope to see others too.
131
94
132
95
### What about scrolling?
133
96
134
-
We have some code close to being published that will manage the scroll
135
-
positions of window and individual elements.
97
+
We have some code close to being published that will manage the scroll positions of window and individual elements.
136
98
137
99
### What about Redux?
138
100
139
101
We have [a `<ControlledRouter>` component](https://github.com/ReactTraining/react-router-addons-controlled) that makes redux
140
-
integration with React Router the same as ... uh ... integrating an
141
-
`<input>` with Redux.
102
+
integration with React Router the same as ... uh ... integrating an `<input>` with Redux.
142
103
143
104
### What about route transition hooks? (example needed)
144
105
145
-
Because we are just components, you have the component lifecycle as
146
-
transition hooks. They are completely parallel. The only difference is
147
-
that the route transition hooks could be asynchronous. The problem with
148
-
that was you weren't in the render lifecycle so you couldn't use React
149
-
to indicate to the user something was happening.
106
+
Because we are just components, you have the component lifecycle as transition hooks. They are completely parallel. The only difference is that the route transition hooks could be asynchronous. The problem with that was you weren't in the render lifecycle so you couldn't use React to indicate to the user something was happening.
150
107
151
108
```js
152
109
<Route onEnter={(_, cb) => {
@@ -157,10 +114,7 @@ to indicate to the user something was happening.
157
114
}}/>
158
115
```
159
116
160
-
One use case was loading data and waiting to render the next screen
161
-
until the data landed. With a component, you can save the previous
162
-
children, render them while loading, and then render your new children
163
-
when you're done. We'll have an example of this eventually.
117
+
One use case was loading data and waiting to render the next screen until the data landed. With a component, you can save the previous children, render them while loading, and then render your new children when you're done. We'll have an example of this eventually.
164
118
165
119
### I liked seeing all my routes in one place, now what?
166
120
@@ -172,38 +126,23 @@ See below
172
126
173
127
### The route config is important to the ecosystem, now what?
174
128
175
-
We have started an addon that we hope people who are interested in this
176
-
will take ownership of here: https://github.com/ReactTraining/react-router-addons-routes
129
+
We have started an addon that we hope people who are interested in this will take ownership of here: https://github.com/ReactTraining/react-router-addons-routes
177
130
178
131
### What about upgrading?
179
132
180
-
We believe very strongly in iterative migration, not rewrites, for
181
-
applications. We are working on a migration guide, but the basic
182
-
strategy is that both versions will be runnable in tandem (due to npm
183
-
limitations, we'll publish the previous version separately so both can
184
-
be installed).
133
+
We believe very strongly in iterative migration, not rewrites, for applications. We are working on a migration guide, but the basic strategy is that both versions will be runnable in tandem (due to npm limitations, we'll publish the previous version separately so both can be installed).
185
134
186
-
You will be able to take routes one-by-one and migrate them to the new
187
-
API. Additionally, the config addon mentioned above may help out here.
188
-
189
-
### What the heck happened to v3?
190
-
191
-
It's in beta, will be released shortly. It's basically just v2 but w/o
192
-
any warnings of deprecated 1.0 API.
135
+
You will be able to take routes one-by-one and migrate them to the new API. Additionally, the config addon mentioned above may help out here.
193
136
194
137
### Do I have to upgrade?
195
138
196
-
No. Leave your package.json at v2/3 and move on with your life. We'll
197
-
be merging bug fixes for v2/3 indefinitely.
139
+
No. Leave your package.json at v2/3 and move on with your life. We'll be merging bug fixes for v2/3 indefinitely.
198
140
199
141
### We're Pumped!
200
142
201
-
We've received a ton of great feedback from people we really admire in
202
-
the React community so we know we've found something special that's a
203
-
bit unprecendented in the world of UI routing.
143
+
We've received a ton of great feedback from people we really admire in the React community so we know we've found something special that's a bit unprecendented in the world of UI routing.
204
144
205
-
We've never been more excited about React Router. It's no longer a
206
-
router for React, it is truly a React Router.
145
+
We've never been more excited about React Router. It's no longer a router for React, it is truly a React Router.
0 commit comments