I would like to pass JSON variable from REACT JS to typescript with click of button:

There are 2 pages:

1. Page 1: userDetails.js (This page redirect after filling a form to the next page "upload")
Submit option

```
let history = useHistory();
const submitForm = (event) => {
event.preventDefault();
try {
let jsonObj = [];
let item = {}
item['project'] = event.target.proj.value
item['corporateId'] = event.target.cid.value
item['backOffice'] = event.target.bo.value
item['environment'] = event.target.env.value

jsonObj.push(item);

console.log(jsonObj);
alert('Your Details are validated!');
history.push({
  pathname: './upload',
     state: jsonObj 
});
setValues({
  proj: '', cid: '', bo: '', env: ''
});
} catch (event) {
alert(`Validation failed! ${event.message}`);
}

}

```
2. Page 2: Upload page where I would like to read the JSON file but this page is in typescript (fileUploader.tsx)

```
 const FileUploader = (): JSX.Element => {
 const { state } = this.props.location
 }

```

Error: this object is possibly undefined.

How can i pass this JSON variable from react JS to react Typescript?