I'd like to render a Tabel component in "/game" route after clicking on a group of difficulty buttons. So the application must pass from route "/" to "/game" rendering a proper tabel depending on a difficulty state set in DifficultyButtons.js. I manage Route components in App.js like this: `
<Route path='/' render={() => <DifficultyButtons/>} />
<Route path='/game' render={() => <Table/>} />
`
In file DifficultyButtons.js redirection starts from clicking on a button that set a state "difficulty" that is going to be used in file Table.js where my purpose is to render a Table proportionally to the difficulty level set. Here's Table.js:
`
const location = useLocation();
const rows = N*location.state;
const columns = M*location.state;
return (
<Table responsive>
<tbody>
{Array.from({length: rows}).map((_, row_index) => (
<tr key={row_index}>
{Array.from({length: columns}).map((_, column_index) => (
<td key={column_index}>
try
</td>
))}
</tr>
))}
</tbody>
</Table>
</div>
)
` Is this the proper way to render the proportional table? I'd like to understand why redirecting to "/game" is not working. Code for redirection in DifficultButtons.js:
{selected ? (
<Redirect to={{
pathname: '/game',
state: {level:difficulty}
}}