Regular render() method behaviour
Everytime we render a component we have to place it within a element-wrapper. Let's say this element is a div with CSS class myDiv.
import React, {Component} from 'react';
class RregularRenderBehaviour extends Component {
render() {
return (
<div className="myDiv">
<p className="myParagraph">Hi!</p>
<p className="myParagraph">Hi!</p>
<p className="myParagraph">Hi!</p>
</div>
);
}
}
Extended render() method behaviour
Maybe it's better to pass render() method two parametres:
- An element that will wrap up our jsx code that is returned (
div) ;
- A CSS class that will be assigned to an element-wrapper (
myDiv).
Here is an example of what I am trying to say.
class ExtendedRenderBehaviour extends Component {
render(div, "myDiv"){
return (
<p className="myParagraph">Hi!</p>
<p className="myParagraph">Hi!</p>
<p className="myParagraph">Hi!</p>
);
}
}
If render() method didnt receive any parametres It will wrap jsx code with a div by default.
I think this enhancement can save time a bit and you dont have to worry that u didnt wrap your jsx code.
Regular
render()method behaviourEverytime we render a component we have to place it within a element-wrapper. Let's say this element is a
divwith CSS classmyDiv.Extended
render()method behaviourMaybe it's better to pass
render()method two parametres:div) ;myDiv).Here is an example of what I am trying to say.
If
render()method didnt receive any parametres It will wrap jsx code with adivby default.I think this enhancement can save time a bit and you dont have to worry that u didnt wrap your jsx code.