Search code examples
reactjsreact-routerreact-router-dom

React wrapper: React does not recognize the `staticContext` prop on a DOM element


I'm trying to create a wrapper component around the react-router-dom NavLink component.

I would like my custom component to accept all of NavLinks props, and proxy them down to NavLink.

However when I do this, I'm getting:

Warning: React does not recognize the staticContext prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase staticcontext instead. If you accidentally passed it from a parent component, remove it from the DOM element.

A working demo of the issue can be found here:


Solution

  • There is a way to overcome that is using:

    const { to, staticContext, ...rest } = this.props;
    

    So your ...rest will never contain staticContext