@fengfeng
2014-09-24T02:56:40.000000Z
字数 2753
阅读 1300
note
React
suppoert ie>=8,but IE8 not support onscroll
Remember, what you return from render() is not your actual rendered children instances. What you return from render() is merely a description of the children instances in your component's sub-hierarchy at a particular moment in time.
<SearchBar
filterText={this.state.filterText}
inStockOnly={this.state.inStockOnly}
onUserInput={this.handleUserInput}
/>
this.props.filterText ==>filterText
by getInitialState init state variable
==> getInitialState: function() {
return {
filterText: '',
inStockOnly: false
};
},
reset state variable
==> this.setState({
filterText: filterText,
inStockOnly: inStockOnly
});
ref the state variable
this.state.inStockOnly ==>inStockOnly
Refs are a great way to send a message to a particular child instance in a way that would be inconvenient to do via streaming Reactive props and state. They should, however, not be your go-to abstraction for flowing data through your application. By default, use the Reactive data flow and save refs for use cases that are inherently non-reactive.
an optional, unique identifier. When your component shuffles around during render passes, it might be destroyed and recreated due to the diff algorithm. Assigning it a key that persists makes sure the component stays. See more here.
takes an object with the key __html and a DOM string as value. This is mainly for cooperating with DOM string manipulation libraries. Refer to the last example on the front page.
Benefits:
Cautions: #
<Parent><Child /></Parent>
Parent can read its children by accessing the special this.props.children prop.