Comments (36)
what is the status of implementing react-router?
from react-starter-kit.
I on the same page with @koistya we shouldn't JSXify everything now, just because we can.
from react-starter-kit.
@langpavel it seems like RR4 doesn't work well with Relay, and there is not a word about async data loading and code-splitting in their docs yet.
from react-starter-kit.
I personally lean towards Flux-based router. Yahoo guys are working in this direction and there is also react-crossroads. Defining routes with JSX/XML looks odd to me. React components already describe view hierarchy, no need to re-implement that at the routing level.
from react-starter-kit.
+1. React-router is doing isomorphic, trying turning off JS for http://react-router-mega-demo.herokuapp.com/ :)
from react-starter-kit.
+1 to react-router
from react-starter-kit.
+1 to react-router as well
from react-starter-kit.
+1 to react-router
from react-starter-kit.
+1 to react-router
from react-starter-kit.
Both are isomorphic, but I guess attaching to a formal react based router is a good choice
+1 to react-router
from react-starter-kit.
Another +1 for react router. It seems like this is becoming the de-facto router to use with react and building isomorphic applications with it is quite trivial.
I actually have an example here that shows how you're able to build isomorphic applications using react-router and flux.
from react-starter-kit.
+1
from react-starter-kit.
+1
from react-starter-kit.
Has anyone successfully gotten this to work on their own project/fork? Would love to see the implementation details. I've only encountered errors trying to integrate it in.
from react-starter-kit.
- 1 for seeing a fork with react-router implemented
from react-starter-kit.
+1
from react-starter-kit.
+1
from react-starter-kit.
+1 to react-router
from react-starter-kit.
+1 for react-router
from react-starter-kit.
+1 for react-router
from react-starter-kit.
+1
from react-starter-kit.
Yeah I'd really like to see an example
from react-starter-kit.
+1
from react-starter-kit.
+1 for react-router
from react-starter-kit.
+1 to react router please
from react-starter-kit.
+1
from react-starter-kit.
+1 to react-router, it's the de facto standard router for react.
from react-starter-kit.
After ff5016f, it might be easier to integrate React Router. The src/routes/index.js
file contains the list of all appliaction routes, where each route has these properties:
path
- a string or regular expression, e.g./posts/:id
(see path-to-regexp, route tester)action
- a route handler that acceptscontext
as its first argument, it can return a Promisechildren
- optional parameter with a list of child routes
For example:
{
path: '/admin',
action() { ... },
children: [
{
path: '/', // www.example.com/admin
action() { ... }
},
{
path: '/users',
children: [
{
path: '/', // www.example.com/admin/users
action() { ... },
},
{
path: '/:id', // www.example.com/admin/users/123
action() { ... },
},
]
}
]
}
An action method may look something like this:
{
path: '/users/:username', // e.g. www.example.com/users/john
async action({ path, render, params }) {
console.log(`handling ${path} route...`);
const resp = await fetch(`/api/users/${params.username}`);
const data = await resp.json();
if (!data) return undefined;
return render(<UserProfile {...data} />);
}
}
If action method returns undefined
, the router will keep traversing the route tree until it finds the first route that matches the provided URL path string and returns anything other than undefined
.
In order to make it work with React Router, (1) the action
property must be replaced with either component
or getComponent
, (2) the children
property must be renamed to childRoutes
, (3) the path
values shouldn't start with /
and follow React Router convention, (4) the match
method inside src/client.js
and src/server.js
should be replaced with React Router's match
method.
Ref #613
from react-starter-kit.
How to handle with the context thing here?
react-router's match doesn't process context for us
from react-starter-kit.
@stupidisum you can set context in the top-level React component, for example, with React Router it would be: const routes = { path: '/', component: App, childRoutes: [/* all the other routes */] }
, where the App
component sets the required context vars (e.g. Flux/Redux/Relay store etc.).
BTW, the routing boilerplate is going to be removed from server.js
and client.js
. See PR #613.
from react-starter-kit.
👍
from react-starter-kit.
+1 for a forked example with react-router
!
from react-starter-kit.
@rkait can you point us to fork with react-router in new issue or better PR?
from react-starter-kit.
@langpavel I am trying to implement something similar to their previous PR in my own project that uses RSK. There are still a few issues, so if anyone else has implemented something more formal that would be very helpful as an example.
from react-starter-kit.
FYI, you can find some of the issues with React Router v2-3 in the official docs:
https://github.com/ReactTraining/react-router/tree/v4
The next version of RR has a completely different API, check it out. Yet, there is no guarantee that RR v4 will not be rewritten into something different in a few months from now.
from react-starter-kit.
@koistya it looks like they are teaches a lot.. RR4 is awesome I think but I didn't tested it. If asynchronous routes, code splitting and other things will work seamlessly after they become stable, RR will be best choice :-)
from react-starter-kit.
Related Issues (20)
- Need help building an old website from 2016 HOT 5
- Error 500: Unexpected token < in JSON at position 0 HOT 3
- SPAM
- 'Cannot find module' Error for cached modules in VSCode HOT 1
- Minor issue running 'Relay' with Yarn HOT 1
- Cannot find module ... TypeScript error in VSCode HOT 1
- Hot Reload not working properly HOT 1
- Hot Reload CSS and JS files changes HOT 1
- Cannot open started application due to Firebase error HOT 2
- site.manifest error - comma missing
- What kind of API token templates should I use? HOT 1
- Where's node_modules?
- Where's node_modules? HOT 1
- Error on first start. TT HOT 2
- Network: use --host to expose HOT 1
- Codespaces not working with "Use Template" (workaround: clone/fork/duplicate repo) HOT 5
- The engine "node" is incompatible with this module. Expected version "10". Got "18.14.0" HOT 5
- Shipping with Google_Cloud_Credentials Issue HOT 2
- Login Dialog is not showing up
- Unable to add packages using Yarn HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-starter-kit.