The question comes from a issue where I need data binding and save it to a reducer so I can use pusher to modify the data when needed and it changes in real-time. The problems I find are that:
I am new in react and I don't really know much about how to bind data variables.
I am using remote data with fetch so the data can be refreshed but it can't seem to find a way to properly bind or even save it to a reducer.
Below, the relevant code:
class MainTable extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<MaterialTable
tableRef={this.tableRef}
columns={columnsSetup}
options={materialTableOptions}
data={query =>
new Promise((resolve, reject) => {
pageQuery = query.page;
pageSizeQuery = query.pageSize;
let url = GET_ORDERS_URL;
url += 'qtt=' + pageSizeQuery;
url += '&page=' + pageQuery;
fetch(url)
.then(response => response.json())
.then(result => {
resolve({
data: result.data,
page: result.page,
totalCount: result.totalElems
});
});
})
}
/>
);
}
}