在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ HTML/ 公開(kāi)組件功能
顯示數(shù)據(jù)
組件的引用
Controlled Input 值為 null 的情況
Reconciliation
子 props 的類型
組件的詳細(xì)說(shuō)明和生命周期
傳遞 Props
特殊的非 DOM 屬性
組件 API
PureRenderMixin
雙向綁定輔助工具
瀏覽器中的工作原理
深入 JSX
表單組件
Dangerously Set innerHTML
入門
JSX 中的 If-Else
克隆組件
教程
更多的關(guān)于Refs
JSX 的 false 處理
高級(jí)性能
Mounting 后 componentWillReceiveProps 未被觸發(fā)
簡(jiǎn)介
測(cè)試工具集
JSX 陷阱
工具集成(ToolingIntegration)
公開(kāi)組件功能
通過(guò) AJAX 加載初始數(shù)據(jù)
事件系統(tǒng)
可復(fù)用組件
this.props.children undefined
不可變數(shù)據(jù)的輔助工具(Immutability Helpers)
動(dòng)態(tài)交互式用戶界面
組件的 DOM 事件監(jiān)聽(tīng)
復(fù)合組件
動(dòng)畫
插件
JSX 展開(kāi)屬性
行內(nèi)樣式
性能分析工具
類名操作
與其他類庫(kù)并行使用 React
鍵控的片段
標(biāo)簽和屬性支持
組件間的通信
React (虛擬)DOM 術(shù)語(yǔ)
JSX 根節(jié)點(diǎn)的最大數(shù)量
在樣式props中快速制定像素值
頂層 API
深入理解 React
自閉合標(biāo)簽
為什么使用 React?
getInitialState 里的 Props 是一個(gè)反模式
與 DOM 的差異

公開(kāi)組件功能

組件之間的交互還有另一種(不常見(jiàn)的)方法:對(duì)父組件要調(diào)用的子組件簡(jiǎn)單的公開(kāi)方法。

以一個(gè)待辦事項(xiàng)列表為例,點(diǎn)擊后該列表會(huì)被刪除。如果只剩下一個(gè)未完成的待辦事項(xiàng),給它添加動(dòng)畫:

var Todo = React.createClass({
  render: function() {
    return <div onClick={this.props.onClick}>{this.props.title}</div>;
  },
  //this component will be accessed by the parent through the `ref` attribute
  animate: function() {
    console.log('Pretend %s is animating', this.props.title);
  }
});
var Todos = React.createClass({
  getInitialState: function() {
    return {items: ['Apple', 'Banana', 'Cranberry']};
  },
  handleClick: function(index) {
    var items = this.state.items.filter(function(item, i) {
      return index !== i;
    });
    this.setState({items: items}, function() {
      if (items.length === 1) {
        this.refs.item0.animate();
      }
    }.bind(this));
  },
  render: function() {
    return (
      <div>
        {this.state.items.map(function(item, i) {
          var boundClick = this.handleClick.bind(this, i);
          return (
            <Todo onClick={boundClick} key={i} title={item} ref={'item' + i} />
          );
        }, this)}
      </div>
    );
  }
});
React.render(<Todos />, mountNode);

或者,你可能已經(jīng)通過(guò)把 isLastUnfinishedItem 道具傳遞給 todo 實(shí)現(xiàn)了上述操作,并讓它在 componentDidUpdate 中檢查道具,然后對(duì)其本身進(jìn)行動(dòng)畫控制;然而,如果你傳遞不同的道具來(lái)控制動(dòng)畫,這很快就會(huì)變得混亂。