React Native what exactly is the (empty) component

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 !

Leave a Comment