[关闭]
@fengfeng 2014-09-24T02:56:40.000000Z 字数 2753 阅读 1300

React note

note React


concept

browser suppoerted

suppoert ie>=8,but IE8 not support onscroll

render

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.

props

  1. <SearchBar
  2. filterText={this.state.filterText}
  3. inStockOnly={this.state.inStockOnly}
  4. onUserInput={this.handleUserInput}
  5. />
  6. this.props.filterText ==>filterText

state

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

ref

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.

key:

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.

dangerouslySetInnerHTML:

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: #

Children

  1. <Parent><Child /></Parent>

Parent can read its children by accessing the special this.props.children prop.

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注