Sunday, May 19, 2024
111
rated 0 times [  118] [ 7]  / answers: 1 / hits: 28561  / 4 Years ago, wed, january 15, 2020, 12:00:00

In React Native you can encapsulate a set of components in one single <View> (or similar) component. You can also encapsulate a set of components as <> and </>. What are these? Do they just translate to an base View? It's probably not a good practice but it doesn't give a warning and it doesn't crash.


More From » react-native

 Answers
24

It's the React shortcut for Fragment component.



You can write like this :



import React, { Component } from 'react'

class Component extends Component {
render() {
return <> <ComponentA/> <ComponentB/> </>
}
}


Or without the shortcut and import Fragment component



import React, { Component, Fragment } from 'react'

class Component extends Component {
render() {
return <Fragment> <ComponentA/> <ComponentB/> </Fragment>
}
}



You have to know, you can't use any key or prop with the shortcut syntax.



Here's the official documentation



I hope it helps !


[#51302] Tuesday, January 7, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
deonkalvinw

Total Points: 409
Total Questions: 96
Total Answers: 89

Location: Saint Pierre and Miquelon
Member since Sun, Nov 27, 2022
2 Years ago
deonkalvinw questions
Sun, Feb 6, 22, 00:00, 2 Years ago
Tue, Dec 28, 21, 00:00, 2 Years ago
Sun, Aug 22, 21, 00:00, 3 Years ago
Sun, Mar 7, 21, 00:00, 3 Years ago
;