Skip to content

Switch component shouldn't have div as children #188

Closed
@jogerj

Description

@jogerj

in Routes.tsx there's a piece of code which will throw warnings

<Switch>
  <Route path="/admin">
    <Admin />
  </Route>
  <div className={classes.app}>
    <header className={classes.header}>
      <Route path="/login" component={Login} />
      <Route path="/signup" component={SignUp} />
      <Route
        path="/logout"
        render={() => {
          logout();
          history.push('/');
          return null;
        }}
      />
      <PrivateRoute path="/protected" component={Protected} />
      <Route exact path="/" component={Home} />
    </header>
  </div>
</Switch>

This will generate the following warning from React:
a warning is prompt from react: React does not recognize the computedMatch prop on a DOM element.

Reason is that div shouldn't be children of Switch component. Possible solutions: the Switch component should instead be inside the div or each component linked in Route should have their own div.

See post here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions