Skip to content

Warnings when using with React-Router #49

@Rakk4403

Description

@Rakk4403

Hello, I'm a freshman in React.

I got this message, but I cannot help avoiding this:

Warning: Unknown props `match`, `location`, `history`, `staticContext` on <div> tag. Remove these props from the element. For details, see https://fb.me/react-unknown-prop

My app is working even with this warnings, but I don't wanna clean up console msgs.

This is my use case:

import { Router, withRouter } from 'react-router-dom';
import { Box, VBox, Container } from 'react-layout-components';

const RoutedVBox = withRouter(VBox);
...
class MyApp extends React.Component {
  render() {
     return (
       <Router>
          <RoutedVBox> ... </RoutedVBox>
       </Router>
     )
  }
}

I tried to removing props of Router(match, location, history, staticContext) by this function, but It breaks successful works.

const MyBox = props => {
  const { match, location, history, staticContext, ...restProps } = props;
  return (<Box {...restProps} />);
}

I just want to remove warning message in console, is there a way for this?
There is no answers in SO.
Should I keep going with warnings?

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