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

setState with function component wrapper #2043

Closed
2 of 13 tasks
eps1lon opened this issue Mar 11, 2019 · 2 comments
Closed
2 of 13 tasks

setState with function component wrapper #2043

eps1lon opened this issue Mar 11, 2019 · 2 comments

Comments

@eps1lon
Copy link
Contributor

eps1lon commented Mar 11, 2019

Current behavior

wrapper.find('DisplayNameOfClassComponent').state() triggers Error: ReactWrapper::state() can only be called on class components when wrapper is a function component even though DisplayNameOfClassComponent is a class component and has state.

Expected behavior

Same behavior if wrapper is a class component or DisplayNameOfClassComponent itself i.e. all 3 test in the codesandbox pass.

Your environment

API

  • shallow
  • mount
  • render

Version

library version
enzyme 3.9.0
react 16.8.3
react-dom 16.8.3
react-test-renderer unknown
adapter (below) 1.10.0

Adapter

  • enzyme-adapter-react-16
  • enzyme-adapter-react-16.3@1.10.0
  • enzyme-adapter-react-16.2
  • enzyme-adapter-react-16.1
  • enzyme-adapter-react-15
  • enzyme-adapter-react-15.4
  • enzyme-adapter-react-14
  • enzyme-adapter-react-13
  • enzyme-adapter-react-helper
  • others ( )
@ljharb

This comment has been minimized.

@eps1lon

This comment has been minimized.

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