Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Props on components' children come in on props.children[0].props.children.props, not on props.children[0].props #84

Closed
valentijnnieman opened this issue Sep 26, 2018 · 4 comments
Assignees

Comments

@valentijnnieman
Copy link
Contributor

One thing that I found weird when writing the Tabs component, is that the props on children components coming from Dash are not available on props.children[0].props(for example, where props.children[0] is a Tab component for instance), but on props.children[0].props.children.props. I've went around this by having some logic saying "if child.props.children exists, the props are coming from Dash, otherwise they're coming from Demo.js", but that causes weirdness when, in JS (Demo.js or perhaps a unit test), you set children on a <Tab/>, causing the logic to pick that up as "oh, these are coming from Dash" and using the child.props.children.props which is then not the props we want!

Hope this makes sense!

@T4rk1n
Copy link
Contributor

T4rk1n commented Sep 26, 2018

I found that weird too, it's the TreeContainer render function that does this.

@chriddyp
Copy link
Member

Right, that's because we wrap each component in a NotifyObservers component. Until tabs was written, we didn't have any components that needed to introspect their children

@valentijnnieman valentijnnieman self-assigned this Sep 26, 2018
@valentijnnieman
Copy link
Contributor Author

Ah cool thanks. Let me see if I can come up with a fix!

@chriddyp
Copy link
Member

This is now available as props._dashprivate_layout

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

No branches or pull requests

3 participants