I am trying to figure out how to convert this code
const Child = ({ match }) => (
<div>
<h3>ID: {match.params.id}</h3>
</div>
)
Into a class based component like this
class Home extends React.Component {
render() {
....
}
}
Normal const components I know how to convert, but I am not able to understand how to include match parameter in class based component.
{ match }would generally either map tothis.props.matchorthis.state.matchin a class based component when you are converting it. Depending on whether match is likely to change during the lifecycle of the component. If match is likely to change, make it a state variable, otherwise, make it a prop variable. Also, how you create the child component in the parent component will need to be reviewed in order to ensure you pass props or state correctly.