I'm using Redux for state management in this extreact powered app that I started and I'm at a component (List
) that needs data from the redux store. The List
component needs a store
parameter that I know how to create but I don't know how to couple it with the redux store.
I found an example from Sencha blog but it's lacking exactly at the part that I'm interested in:
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Grid } from '@extjs/ext-react';
import { connect } from 'react-redux';
export default class EmployeesGrid extends Component {
static propTypes = {
criteria: PropTypes.object
};
store = new Ext.data.Store({
...
});
componentDidUpdate(prevProps) {
const { criteria } = this.props;
if (prevProps.criteria !== criteria) {
const filters = [];
for (let name in criteria) {
filters.push({
property: name,
value: criteria[name]
})
}
this.store.filter(filters)
}
}
render() {
return (
<Grid
store={this.store}
...
/>
)
}
}
const mapStateToProps = (state) => {
return { criteria: state.criteria }
};
export default connect(mapStateToProps)(EmployeesGrid);
How does the Ext.data.Store
gets the items and how are those items updated on componentDidUpdate
for example?