gusti
gusti

Reputation: 543

React Router - page is not re-rendered at route change

I have a simple app where I try to interchange between 2 routes, and for each route there is a specific component to be rendered. Unfortunately, it seems like it remains stuck on the first Route I set inside the Switch.

Here you can access a sandbox containing the simplified app. I have set 2 NavLink components to manage the 2 routes.

Upvotes: 0

Views: 17

Answers (1)

Nokwiw
Nokwiw

Reputation: 396

in the builer component, you should use path instead to :

            <Route path="/checkout" exact render={() => <div>Checkout</div>} />

            <Route path="/" exact>
              {this.state.showModal ? <div>Modal {orderSummary}</div> : null}

              <div>Main Page</div>

              {this.state.error ? errorMessage : ingredientControls}
            </Route>

I tried it, it's work

Upvotes: 1

Related Questions