Please tell me the difference in writing between:
render() { return( <Button>test</Button> ) } and
render() { let testButton = ( <Button>test</Button> ) return( {testButton} ) } Please tell me the difference in writing between:
render() { return( <Button>test</Button> ) } and
render() { let testButton = ( <Button>test</Button> ) return( {testButton} ) } The second will not work. Because the extra brackets {} cause the render method to return a regular javascript object and not a jsx component. It is necessary so:
render() { let testButton = ( <Button>test</Button> ) return( testButton ) } Now, if you write like this - there is no difference. Why not? Because jsx is translated to js, ​​and the first and second options are converted to almost equivalent js.
See how jsx broadcasts such as babel here.
The fact that for other jsx translators the code should be the same in meaning, I'm not 100% sure. Confident at 99.9%. You can rely on 100% by immersing yourself in the official jsx specification.
You can read about the nuances of jsx in human language in the documentation from Facebook
Source: https://ru.stackoverflow.com/questions/574188/
All Articles