をReact.Children.map
から文字列変数に変更しようとすると、そのノードの色を動的に変更して、色を変更して動的に色を変更します。私は私のホームページにタイトルを持っています。私はタイトル文字列内の各文字のノードの色を更新したい。このようにそれをやろうとしているが、誤差エン取得:Cannot read property 'colorString' of undefined
ReactJsでは、文字列変数
const LetterStyle = React.createClass({
colorString: function(value){
this.setState({color: "green"});
},
render: function(){
const colorArray = []
var childrentWithProps = React.Children.forEach(this.props.children, (child, i) => {
for (var i=0; i<child.length; i++){
return React.Children.map(child[i], function(content, i) {
if(content !== " "){
React.cloneElement(content, { colorString: this.colorString })
}
});
}
})
return(
<h1 className="lead" ref="lead">
<span>{childrentWithProps}</span>
</h1>
);
}
});