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

refs are not triggered on root elements #1504

Closed
2 of 10 tasks
pfhayes opened this issue Feb 1, 2018 · 2 comments
Closed
2 of 10 tasks

refs are not triggered on root elements #1504

pfhayes opened this issue Feb 1, 2018 · 2 comments

Comments

@pfhayes
Copy link
Contributor

pfhayes commented Feb 1, 2018

Refs on the mounted root element do not appear to be triggered. Is this expected behaviour?

  it('triggers refs on child elements', (done) => {
    mount(<div><span ref={(c) => done()}/></div>);
  });

  it('triggers refs on root elements', (done) => {
    mount(<span ref={(c) => done()}/>);
  });

Current behavior

The child elements test passes, but the root element test fails

Expected behavior

Both tests should pass

API

  • shallow
  • mount
  • render

Version

library version
Enzyme 3.3.0
React 16.2.0

Adapter

  • enzyme-adapter-react-16
  • enzyme-adapter-react-15
  • enzyme-adapter-react-15.4
  • enzyme-adapter-react-14
  • enzyme-adapter-react-13
  • enzyme-adapter-react-helper
  • others ( )
@ljharb
Copy link
Member

ljharb commented Feb 2, 2018

Does this happen with other versions of react as well?

@pfhayes
Copy link
Contributor Author

pfhayes commented Feb 2, 2018

I was able to reproduce this in React 16.0.0 and 15.0.0

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