React.Children.map recursively?

后端 未结 5 1846
青春惊慌失措
青春惊慌失措 2020-12-13 19:53

I\'m building a React Component for rendering an HTML form and I\'m finding the need to recursively iterate through all children of my parent Form component in order to add

5条回答
  •  没有蜡笔的小新
    2020-12-13 20:43

    If you're looking to push props into a set of children under your component "automatically", you can also use context. This allows you to "give" properties, functions, etc. to child components by providing them from the parent with childContextTypes and getChildContext(), and having the child "request" them with contextTypes.

提交回复
热议问题