2

ReactDOM.render(element, container [,callback])

in the above method what is meant by [,callback] parameter?

3 Answers3

2

Well its an optional parameter.As its a callback you can pass a function as parameter to be called when the component has rendered or updated

ReactDOM.render(<App />, document.getElementById('root'),()=>{
  console.log("rendered the root componnet");
});
Abhijet
  • 155
  • 1
  • 13
1

As mentioned in the react doc :

If the optional callback is provided, it will be executed after the component is rendered or updated.

So callback is the optional argument which would also be a function and this function would be executed after component is rendered or updated. As callbacks are referred to as functions called after completion, it will be executed after rendering component.

Umair Farooq
  • 1,763
  • 13
  • 16
0

The callback is the function you want it to be executed after the component is rendered. The [] means it's optional.

Emily
  • 191
  • 1
  • 4