question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

can't access children from <Connect(Component)>

See original GitHub issue

Calling React.Children.only() on a Connect(Component) generated by the react-redux connect function does not expose its children.

Here’s a screenshot of calling React.Children.only(component) on a plain React component:

image

And here’s one of calling React.Children.only(component) on a Connect(Component) generated by the connect function:

image

I need access to the Connect children because I have a component wrapper that injects a prop into deeply nested children of a certain type.

Does this make sense?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
gaearoncommented, Feb 13, 2018

That’s not how React works. Components rendered by something are the implementation detail. You can manipulate children that you create in your component, but you can’t use it as an “introspection” tool to manipulate the output of other components.

0reactions
nowaycommented, Jul 12, 2019

I found this thread because I’m trying to implement a custom module in react native. For anyone trying to access props.children of a component in react native, try the native methods - (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex and - (void)removeReactSubview:(UIView *)subview instead of iterating react elements in javascript

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cant access children in component used as element in Route ...
Fragment components are the only valid children of the Routes component, and other Route components the only valid children of the Route ....
Read more >
How to access props.children in a stateless functional ...
Import the child component into the parent component, but instead of invoking it with a self-closing tag, use a standard open/close tag.
Read more >
How to access child component properties in Vue.js 3
Accessing components with refs is possible due to the open nature of components in Vuejs2. While in Vuejs 3 components are closed by...
Read more >
How to call the child component function from the parent ...
Here we have a parent component with a button and a child component with a function to show an alert. If you want...
Read more >
Unable to access parent component value in child js controller ...
and if you want ot pass from connectedCallback then you should refer the same name and it should be used as attribute and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found