react-router contains all the common components between react-router-dom and react-router-native. When should you use one over the other? If you're on the web then react-router-dom should have everything you need as it also exports the common components you'll need. If you're using React Native, react-router-native should have everything you need for the same reason. So you'll probably never have to import anything directly from react-router. As far as when you use
In RRv4 you won't need to pass down browserHistory, that was just for previous versions of the router.
If you're still confused, you can check out the details on each package here
Found this in the Github.
Note: This package provides the core routing functionality for React Router, but you might not want to install it directly. If you are writing an application that will run in the browser, you should instead install
react-router-dom. Similarly, if you are writing a React Native application, you should instead install
react-router-native. Both of those will install
react-router as a dependency.
In v4, react-router exports the core components and functions. react-router-dom exports DOM-aware components, like
<Link>( which renders
<a>) and (which interacts with the browser's window.history ).
react-router-domre-exports all of react-router's exports, so you only need to import from
react-router-domin your project.
react-router-dom re-exports all of
react-router. The link on GitHub answer (what's the diff between
react-router-dom is a
some Link improvements for browser
<NavLink>— wrapper that knows if it's "active" or not
- How can I use useEffect in React to run some code only when the component first mounts, and some other code whenever an event occurs (repeatedly)?
- react router dom not working when changing the path
- React Router rendering only base path (/) and throwing error for other paths when requested directly in the browser
- When click in one element, the other ones disable in React JS
- React child components are only half updating when switching from one to the other
- How to use React Router properly? I am trying to push the state of my application to another page when the user logs in
- When I use react router with webpack, it shows the error "React.createElement: type is invalid"
- Componets are overlapping - showing one over the other - react router v5
- How to disable particular route when other one is active in react router
- I cant use framer motion when using <navigate/> react router dom v6 to auth my login page
- React router dom NavLink only works when refresh no when click the nav item
- How to use methods defined in one js file to the other js file in react project
- React Router Dom how to redirect to Other App.js route when you are in any subRoute of any route
- Prevent Component Rendering when i use navigate in react router dom v6
- React Router gets 404 error when going to the website's other URL in AWS EC2
- react-router vs react-router-dom, when to use one or the other?
- React functional stateless component, PureComponent, Component; what are the differences and when should we use what?
- You should not use Route or withRouter() outside a Router when using react-router 4 and styled-component in react
- React useEffect Hook when only one of the effect's deps changes, but not the others
- Removing an item causes React to remove the last DOM node instead of the one associated with that item
- How to pass the match when using render in Route component from react router (v4)
- "Cannot read properties of undefined (reading 'pathname')" when testing pages in the v6 React Router
- What are the scenarios one should use isRequired for PropType vs defaultProps in React Application
- React + Redux + Router - should I use one state/store for all pages/components?
- how to pass props to the route when using react router <Link>
- How do you pass data when using the navigate function in react router v6
- Should one use const when declaring an arrow function in React class
- How to use React.FC<props> type when the children can either be a React node or a function
- ReactJS- Use slug instead of Id in the URL with React router
- Can we cancel out api response when the react router is changed?
More Query from same tag
- ReactJS How to use Router's props inside app.js file
- Initialize react state using function
- Passing any arbitrary function as a property value to Typescript React Component
- Hide permanently password attributes from Prisma Database Query
- What icons can be added from different versions of material-ui/icons in a react project?
- Immutable.js relationships
- Webpack successfully compiled but does not show output in browser
- How can I deal with setState being asynchronous?
- How to get params from route in REACTJS
- Dropdown sorted by categories
- Hot reload in Electron/React application
- Difference between event.target.value and event.currentTarget.value
- pagination does not work correctly next/preview
- How to refactor code with ternary operators using react?
- How to get object key and value without knowing directly object key?
- React router not rendering component
- React.js 2-way bindings: two-levels deep path in valueLink
- React + Material UI + Typescript + Webpack + SSR not working
- How to import a component or file in React using variables?
- React js quill image upload
- Setting Up Django and React
- react-photo-gallery don't change photos via state
- How can I have an image that changes every 5 seconds in react.js?
- Fetch graphql query result on render and re-renders BUT LAZILY
- Embed react component into website without Iframes
- React/Webpack site suddenly loses CSS
- axios post sent request twice
- setState for a 2 level nested array of object
- Correct way to use state in React
- New compilation errors with react-addons-test-utils