Code Sample for State of a Component in React

Hello Everyone, Can anyone suggest me below sample is right to update the state of a component in React? I am preparing for my upcoming react interview, So your suggestions are very helpful to me.

class MyComponent extends React.Component {
constructor() {
super();
this.state = {
name: ‘Akhil’,
id: ‘101’
}
}
render()
{
setTimeout(()=>)},2000)
return (
Hello
Your Id is
);
}
}
ReactDOM.render(
, document.getElementById(‘content’)
);

Hi @aartiyadav

I think if you want help on React specific questions, you’ll want to take a look at the Where To Get Support page from React. They mention some places where your questions are likelier to answer.

This forum is specific to Solid related questions, so if you have questions for that feel free to ask here. (And feel free to take a look at Solid too, it’s an interesting project :))

1 Like