what's the diff between `react-router-dom` & `react-router`?
xgqfrms-GitHub opened this issue ยท 9 comments
https://github.com/ReactTraining/react-router
$ npm install --save react-router
// using an ES6 transpiler, like babel
import { Router, Route, Link } from 'react-router'
https://reacttraining.com/react-router/
$ npm install react-router-dom@next
# or
$ yarn add react-router-dom@next
import {
BrowserRouter as Router,
StaticRouter, // for server rendering
Route,
Link
// etc.
} from 'react-router-dom';
Your first link is to the master branch, which at this time is v3.
In v4, react-router
exports the core components and functions. react-router-dom
exports DOM-aware components, like <Link>
(which renders an <a>
) and <BrowserRouter>
(which interacts with the browser's window.history
).
react-router-dom
re-exports all of react-router
's exports, so you only need to import from react-router-dom
in your project.
Thanks a lot! ๐
So in the future, which is now where RR4 is released, which one shall we use for Web development only? Do we just do "yarn add react-router" will do?
You'll use the bindings for your environment. You will probably want to use react-router-dom for 99.9% of web dev.
@pshrmn, thanks !
This helped alot, thanks!
@pshrmn repurposed your answer into documentation ^^^ I think this issue should be re-opened until the documentation is addressed, obviously lots of people have hit this.