这是代码:
const mapStateToProps = (state, ownProps) => {
const id = ownProps.match.params.id;
const sheets = state.firestore.data.sheets;
const sheet = sheets && sheets[id];
const rows = sheet.rows;
return {
rows: rows,
};
};
export default compose(
firestoreConnect(() => ["sheets"]),
connect(mapStateToProps)
)(Table);
数据结构:
sheets:[
filename:'abc.txt',
rows:[ {somedata} , {somedata} ]
]
在加载页面时,我可以加载行,但在重新加载时,我会丢失状态中的数据。这是错误:
TypeError:无法读取未定义的属性“行”