2017-06-12 25 views
0

私はFramework ReactJSを初めて使用しており、1ページに2つの異なる取得をしようとしています。各getは異なるデータベースの異なる配列を受け取ります。 この間違いを理解できたら助かりますか?このリンクは、それが同じ問題を持っているのに役立ちます未定義のプロパティ 'slice'を読み取ることができません

Error_slice

class Example extends React.Component{ 

constructor (props) { 
     super(props); 
     this.props.dispatch (get1({email:this.props.email}),get2({email:this.props.email})); 
     this.options = { 
     onPageChange: this.onPageChange.bind(this), 
     onSizePerPageList: this.sizePerPageListChange.bind(this) 
     }; 
} 

sizePerPageListChange(sizePerPage) { 
    alert(`sizePerPage: ${sizePerPage}`); 
    } 

    onPageChange(page, sizePerPage) { 
    alert(`page: ${page}, sizePerPage: ${sizePerPage}`); 
} 

componentDidMount() { 
      setTimeout(() => { 
       this.refs.table2.forceUpdate(); 
       this.refs.table3.forceUpdate(); 
      }, 500); 
} 


    render() { 


    return (


<table width={1000} height={500}> 
<tr> 
    <td> 
     <BootstrapTable ref="table2" data={ this.props.array_1 } 
      options={ this.options } multiColumnSort={ 2 } striped hover> 
        <td dataField='att_1' isKey={true} width="55px">Col_1</td> 
        <td dataField='att_2' width="140px">Col_1</td> 
        <td dataField='att_3' width="140px">Col_2</td> 
        <td dataField='att_4' width="30px">Col_3</td> 
     </BootstrapTable> 
    </td> 
    <td width={50}> </td> 
    <td> 
     <BootstrapTable ref="table3" data={ this.props.array_2 } 
      options={ this.options } multiColumnSort={ 2 } striped hover> 
        <td dataField='att_5' isKey={true} width="55px">Col_4</td> 
        <td dataField='att_6' width="140px">Col_5</td> 
        <td dataField='att_7' width="30px">Col_6</td> 
     </BootstrapTable> 
    </td> 
</tr> 
</table> 


    ); 
    } 
}; 


function mapStateToProps(state){ 
    return{ 
    array_1: state.proj.array_1, 
    array_2: state.hist.array_2, 
    email: state.email 
    }; 
} 


export default connect(mapStateToProps,{get1,get2})(Example); 
+0

'this.props.array_1'(とおそらく' this.props.array_2')は定義されていないようです。それらをあなたのコンポーネントに小道具として送っていますか?あなたの "取得"がhttp GETである場合、コンポーネントをレンダリングしようとする前に応答を待つ必要があるかもしれません。それは理にかなっていますか?実際のデータを取得する前にレンダリングしている可能性があります。 – byumark

答えて

0

perfaps: link

私が思うには、それが唯一の配列を受け入れますので、bootstrapTableのデータに空のオブジェクトを渡すの問題です。

関連する問題