react-props

How to safely inject props into React children?

让人想犯罪 __ 提交于 2020-08-05 11:08:59
问题 I am building a React component which delays the unmounting of its children in order to animate them. When unmounting, I would like to pass in an additional prop (for example, a data-attribute or a class name) in order to handle animations. This is a specific instance of a general situation where I want override certain properties of children. I have come to realize that the following pattern does exactly what I want: this.props.children.map(child => <child.type key={child.key} ref={child.ref

How to safely inject props into React children?

社会主义新天地 提交于 2020-08-05 11:08:56
问题 I am building a React component which delays the unmounting of its children in order to animate them. When unmounting, I would like to pass in an additional prop (for example, a data-attribute or a class name) in order to handle animations. This is a specific instance of a general situation where I want override certain properties of children. I have come to realize that the following pattern does exactly what I want: this.props.children.map(child => <child.type key={child.key} ref={child.ref

How to safely inject props into React children?

僤鯓⒐⒋嵵緔 提交于 2020-08-05 11:08:52
问题 I am building a React component which delays the unmounting of its children in order to animate them. When unmounting, I would like to pass in an additional prop (for example, a data-attribute or a class name) in order to handle animations. This is a specific instance of a general situation where I want override certain properties of children. I have come to realize that the following pattern does exactly what I want: this.props.children.map(child => <child.type key={child.key} ref={child.ref

How to safely inject props into React children?

纵饮孤独 提交于 2020-08-05 11:08:32
问题 I am building a React component which delays the unmounting of its children in order to animate them. When unmounting, I would like to pass in an additional prop (for example, a data-attribute or a class name) in order to handle animations. This is a specific instance of a general situation where I want override certain properties of children. I have come to realize that the following pattern does exactly what I want: this.props.children.map(child => <child.type key={child.key} ref={child.ref