Skip to content

Unexpected behaviour when composing components and root element is a component #1089

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

Closed
Aferz opened this issue Jan 3, 2019 · 2 comments
Closed
Labels

Comments

@Aferz
Copy link

Aferz commented Jan 3, 2019

Version

1.0.0-beta.28

Reproduction link

https://codesandbox.io/s/lx2r4qv33l

Steps to reproduce

Check the codesandbox. (Console)

What is expected?

I need to check the value set in to prop for the Layout component.

What is actually happening?

The Page component sets to prop for Layout component, but is not possible to test because wrapper.props() returns {} and wrapper.attributes() returns { to: [Object object] }


Is highly possible that I'm misunderstanding some basic functionality. In that case, how could I test the value of to prop is correctly set from Page?

Thanks

@Aferz Aferz changed the title Unexpected when composing components and root element is a component Unexpected behaviour when composing components and root element is a component Jan 3, 2019
@Aferz
Copy link
Author

Aferz commented Jan 3, 2019

After some deep research I've found this issue that may be related to current one.

#640

If that is the case, feel free to close this.

Cheers.

@eddyerburgh
Copy link
Member

eddyerburgh commented Jan 20, 2019

This is different to that issue. The confusing behavior is because props returns the props of the root instance (Page), but attributes returns the attributes of the root DOM element, which is the Layout stub. If you get a wrapper of Layout, by calling find with Layout as a selector, you will get the expected behavior:

wrapper.find(Layout).props()

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

No branches or pull requests

2 participants