Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch component shouldn't have div as children #188

Open
jogerj opened this issue May 10, 2022 · 0 comments
Open

Switch component shouldn't have div as children #188

jogerj opened this issue May 10, 2022 · 0 comments

Comments

@jogerj
Copy link

jogerj commented May 10, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant