I´m pretty new to Typescript and to be honest I still struggle a lot with very basic functions. My situation is this: I have an array with objects (8 attributes per object). On my page I loop through this array and display some of the data for each object. For every displayed object there is a Button/ Link through which I link to the next page (zuBewrtenderTest.tsx). I want to pass one attribute (UniqueID) from the selected object to the next page so I can access the right object from the array again. Anyhow I dont know how to pass the data/ access it. Using the redux store for this seems a little bit of an overkill to me because I really just need to pass this one int.
I tried this solution: Passing Data to Another Component OnClick --> But I cant get it to work because this and props is not allowed anymore in typescript
This is my code
function tests() {
//Test Navigation
<Route path="/zuBewertenderTest/:name" exact component={ZuBewertenderTest}></Route>
//Test um
const classes = UseStyles();
return (
<div className={classes.root}>
<Grid className="container" container spacing={3}>
<Grid item xs={12}>
<Paper className={classes.paper}></Paper>
</Grid>
{testDaten.map((item, key) => {
return (
<Grid item xs={4} sm={4} key={item.UniqueId}>
<Input value={item.UniqueId} type="number" id="idTest"/>
<Paper className={classes.paper}> Besucher-Id: {item.UniqueId} </Paper>
<Paper className={classes.paper}> Name: {item.Vorname} {item.Nachname}</Paper>
<Paper className={classes.paper}> Nachweisart: {item.Nachweisart} </Paper>
<Paper className={classes.paper}> <Link to={`/zuBewertenderTest/${item.UniqueId}`}>More info</Link> </Paper>
</Grid>
)
})}
</Grid>
</div>
);
}