I'm trying to navigate to another component upon the Food Truck
button being clicked. In the nextPage()
function, I'm trying to make that happen but it just keeps throwing me an error.
How can I go from page to the next when clicking a button?
Note: I want to go to a totally different page, not stay on the same page.
import React, { Component } from "react";
import fire from "../../config/Fire";
import classes from "./Home.css";
import Aux from "../../hoc/Aux";
import Taco from "../../components/taco/Taco";
class Home extends Component {
constructor(props) {
super(props);
this.state = {
taco: {}
};
}
nextPage() {
return this.state.taco ? <Taco /> : <Home />;
}
render() {
return (
<Aux>
<h1 className={classes.ChooseTruck}>Choose your favorite truck!</h1>
<button
type="button"
className="btn btn-outline-primary btn-lg btn-block"
onClick={this.nextPage}
>
Food Truck
</button>
</Aux>
);
}
}
export default Home;