Here is the code:
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);
data structure:
sheets:[
filename:'abc.txt',
rows:[ {somedata} , {somedata} ]
]
On loading the page I'm able to load rows, but on reloading I lose the data in state. Here is the error:
TypeError: Cannot read property 'rows' of undefined
Since you are using redux, there is a package to help you persist your data in local storage it is called redux-persist. You will have your state even if refreshing/closing the page