relay-tools/react-router-relay

improve README to explain where applyRouterMiddleware come from?

gre opened this issue · 11 comments

gre commented

I guess it's from react-router, but in all the code sample in the README it's undefined.

adding the import would help getting started.

taion commented

Well, so are all the other router-related imports, though.

I wonder if the issue is more the docs on React Router?

gre commented

I usually expect getting started code to be complete. Of course yeah we can explore more docs, but I think it is better for new user that a code can be just dropped in and it works.

gre commented

especially for everything related to imports.

gre commented

applyRouterMiddleware is part of the "how to use this lib"

taion commented

I mean the issue essentially is that the right way to write those imports looks like:

import applyRouterMiddleware from 'react-router/lib/applyRouterMiddleware';
import IndexRoute from 'react-router/lib/IndexRoute';
import Route from 'react-router/lib/Route';
import Router from 'react-router/lib/Router';

which is a lot of boilerplate.

gre commented

maybe just

import {applyRouterMiddleware,...} from 'react-router';

applyRouterMiddleware is an hidden feature of react-router, so better say where it is, VS the *Route being the basic usage of react-router (so for these, make sense to not mentioned them)

gre commented

anyway. if you think it's useless. feel free to close this issue, people will still find it when googling..

taion commented

I agree that applyRouterMiddleware is under-documented. I just wonder if I'd be better off adding more docs on the React Router side.

elado commented

I use

import { Router, Route, IndexRoute, Link, browserHistory, applyRouterMiddleware } from 'react-router'

Totally agree this should be on react-router-relay docs. applyRouterMiddleware might not be relevant to react-router's getting started guide, but it's definitely necessary here. When I started with relay router it took me a few minutes/googling to figure out where this function comes from.

taion commented

That's part of the problem though. That's not the right way to import stuff from React Router unless you're using babel-plugin-lodash.

It should be

import Router from 'react-router/lib/Router';

but I don't want a half-dozen lines of that sort of router import at the top of my example, and I don't want to demonstrate an incorrect import style for another library either.

taion commented

Well, I guess how you do imports from React Router is not the concern of this library. And I do the same thing on react-router-scroll anyway.