I am currently working on an application using Redux-React. However, I encountered an error while working on my main project files:
It seems like your post consists mostly of code; could you please provide more details along with it? It looks like your post consists mostly of code; could you please add some more information.It looks like your post consists mostly of code; could you please add some more information.
https://i.sstatic.net/4ONHG.jpg
Here are the key project files:
app.js(component):
import React from 'react';
import { Component } from 'react';
import { connect } from 'react-redux'
import { fetchData } from '../actions';
import TableData from "./TableData";
import TableSearch from "./TableSearch";
export function searchFilter (search, data) {
return data.filter(n => n.term.toLowerCase().includes(search));
}
const days = ["23-08-2019", "24-08-2019", "25-08-2019"];
class Root extends React.Component {
componentDidMount() {
this.props.onFetchData(this.props.day);
}
render() {
const { search, shift, data, filteredData, onFilter, onSetSearch, onFetchData } = this.props;
return (
<div>
<TableSearch value={search}
onChange={(e) => onSetSearch(e.target.value)}
onSearch={() => onFilter()} />
{days.map((day, i) => (
<button key={day}
onClick={() => onFetchData(day)}
className={i === day ? "active" : ""}>{day}</button>
))}
<br />
{Object.keys(data).map(n => (
<button data-shift={n}
onClick={(e) => onFilter({ shift: e.target.dataset.shift })}
className={n === shift ? "active" : ""}>{n} shift</button>
))}
<TableData data={filteredData} />
</div>
);
}
}
export const ConnectedRoot = connect(
(state) => state,
(dispatch) => ({
onFilter: (args) => dispatch({ type: 'RUN_FILTER', ...args }),
onSetSearch: (search) => dispatch({ type: 'SET_SEARCH', search }),
onFetchData: (day) => dispatch(fetchData(day))
})
);