I'm working with react-router-dom V4.2.2 and i have this code ****EDITED****
<BrowserRouter>
<div>
<Switch>
<Route exact path="/" component={App}/>
<Route exact path="/list-days" component={App}>
<Route exact path=":filter" component={App}/>
</Route>
<Route exact path="/add-day" component={App}/>
<Route component={Whoops404}/>
</Switch>
</div>
</BrowserRouter>
and this
const filteredDays=(!filter || !filter.match(/sunny|rainy/))? days : days.filter(day => day[filter] )
and this
<thead>
<tr>
<th>Date</th>
<th>Resort</th>
<th>Rain</th>
<th>Sun Shine</th>
</tr>
<tr>
<td colSpan={4}>
<Link to="/list-days" className="sub-li">All Days</Link>
<Link to="/list-days/rainy" className="sub-li">Rainy Days</Link>
<Link to="/list-days/sunny" >Sunny Days</Link>
</td>
</tr>
</thead>
<tbody>
{filteredDays.map((day,i)=>
<PartyDayRow Key={i}
{...day} />
)}
</tbody>
and finally this
render() {
return (
<div className="app">
<Menu/>
{(this.props.location.pathname==="/")? <PartyDayCount total={this.countDays()} rain={this.countDays("rainy")} dry={this.countDays("sunny")}/> :
(this.props.location.pathname==="/add-day")? <AddDayForm/> : <PartyDayList days={this.state.allPartyDays} filter={this.props.params.filter} />
}
</div>
)
}
I'm trying to make it such that when I click on rainy days or sunny Days, it filters the result using "filteredDays" but it isn't working. I keep getting this error that says "TypeError: Cannot read property 'filter' of undefined" and I noticed the error comes from this "filter={this.props.params.filter}". What am I doing wrong?