Working with React Router trying to get a working to get back to the homepage. However, when you click the Link right now nothing happens.
I've tried using this link with location along with setting it to an object, neither of them are allowing me to navigate to the homepage. I found this question which suggests tying it to an onClick event and then passing the state that I need in a handler. How to use onClick event on react Link component?
Update: The route I am trying to hit
<Route
path="/"
exact
render={(routeProps, props) =>
this.state.fetchedweatherdata ? null : (
<Form
{...routeProps}
{...props}
onChange={this.handleChange}
{...this.state}
onSubmit={this.onSubmit}
/>
)
}
/>
This is the Link under my DisplayWeather component that currently doesn't work
<Link to="/" onClick={() => this.props.fetchedWeatherData}>
Click here to go back to form
</Link>
I am passing the opposite of the state of fetchedWeatherData down to the component because I want it to return to the form.
I want to be able to click the link and return back to the form for the user to submit new weather search queries. Here is a gist with more code to see how it all functions together https://gist.github.com/dhuang612/11f124274022a8188b4b0981dd6932f9
Thanks for any help provided!