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

Warning when mounting component with forwardRef #1844

Open
michal-lipski opened this issue Sep 28, 2018 · 2 comments
Open

Warning when mounting component with forwardRef #1844

michal-lipski opened this issue Sep 28, 2018 · 2 comments

Comments

@michal-lipski
Copy link

michal-lipski commented Sep 28, 2018

Describe the bug
When mounting component that uses forwardRef I am getting a warning:
Warning: Failed prop type: Invalid prop 'Component' supplied to 'WrapperComponent'.
There is no warning when rendering the component in the browser.

To Reproduce
Component:

export const IconButton = React.forwardRef((props, ref) => {
  return (
    <div onClick={props.onClick} ref={ref}>
      {props.children}
    </div>
  )
})

Code in tests that is giving a warning

mount(<IconButton onClick={onClick}>
      <div className={'my-content'} />
    </IconButton>)

Expected behavior
No warning in console

Version
react: 16.3.1
enzyme: 3.6.0
enzyme-adapter-react-16: 1.5.0
enzyme-adapter-utils: 1.8.0
jest: 23.6.0
jest-enzyme: 6.1.2

@ljharb ljharb changed the title Warning when mounting componenet with forwardRef Warning when mounting component with forwardRef Oct 1, 2018
@ljharb
Copy link
Member

ljharb commented Oct 1, 2018

Please fill out the entire issue template - what version of which adapter are you using, and which version of react?

@ljharb
Copy link
Member

ljharb commented Oct 4, 2018

fwiw, #1817 will fix reporting the name incorrectly, if you set .displayName on IconButton.

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

No branches or pull requests

2 participants