Skip to content

Invariant failed: You should not use Route outside a < Router > Webpack production #6738

@RachitKalra

Description

@RachitKalra

I started a new pet project setting up webpack for react in order to understand the working of webpack better, my aim was to set up server side rendering and client rendering

while in development mode is working fine however in production mode I get an error rendering the React element on server side

Invariant failed: You should not use Route outside a < Router >

It must be something related to webpack optimizing the code , but i am not able to pin point it

React router 4.2.0 is working fine , however with react router 5.0.0 is not working. I tried other solutions like

using only react router
importing static router from react-router import {StaticRouter} from "react-router"
but nothing worked, I have set up a repo on github

Version

5.0.0

Test Case

https://github.com/RachitKalra/react-setup

Steps to reproduce

Just install the node dependencies and run npm debug for development mode and npm start for production mode ( causing the error )

Expected Behavior

Actual Behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions