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

Nicolas Widart picture Nicolas Widart · Mar 19, 2018 · Viewed 54.1k times · Source

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:

Answer

Khoa picture Khoa · Mar 19, 2018

There is a way to overcome that is using:

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

So your ...rest will never contain staticContext