欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

左右联动列表

程序员文章站 2022-06-15 22:43:58
...
 render(): React.Node {
    return (
      <VirtualizedSectionList
      {...this.props}
      ref={this._captureRef}
      getItemCount={items => items.length}
      getItem={(items, index) => items[index]}
    />
    );
  }

  _wrapperListRef: ?React.ElementRef<typeof VirtualizedSectionList>;
  _captureRef = ref => {
        /* $FlowFixMe(>=0.99.0 site=react_native_fb) This comment suppresses an
         * error found when Flow v0.99 was deployed. To see the error, delete this
         * comment and run Flow. */
        this._wrapperListRef = ref;
  };
/****************************************
  scrollToIndex = (params: {animated ?: ? boolean, index: number, viewPosition?: number }) => {
        this._wrapperListRef.scrollToIndex(params);}
********************************************/

根据搜索到的rn左右联动,修改源码,注意添加/*****/中的代码