I am new in react, and I am working on a project. I have two pages/components. I take details of user on page and want to show data on another page. But I am not able to do it. Can somebody please help.
This is my first page Personal.js
import React from "react";
import { Form, Row, Col, Button } from "react-bootstrap";
import "bootstrap/dist/css/bootstrap.min.css";
// import bootstrap from "bootstrap";
import { Link } from "react-router-dom";
class Personal extends React.Component {
constructor(props) {
super(props);
this.state = {
name: "",
};
}
render() {
return (
<>
<h2 className="text-center my-4">Personal Information</h2>
<div expand="md" className="container my-4 ">
<Form >
<Row className="my-4">
<Col>
<Form.Label>First Name</Form.Label>
<Form.Control id="first_name" placeholder="First name" />
</Col>
</Row>
<Link to="/Final">
<Button
onClick={() =>
this.setState({
name: document.getElementById("first_name").value,})}
variant="outline-primary">{" "}Next</Button>{" "}
</Link>
</div>
</div>
</>
);
}
}
export default Personal;
And this is my Second Page Final.js
import React from "react";
import { Link } from "react-router-dom";
const Final = (props) => {
return (
<>
<h2>Your Name{this.props.name}</h2>
</>
);
};
export default Final;