What is the syntax to use React fragments in Reason-React

66 Views Asked by At

There is this old chat that suggests writing your own fragment wrapper, but I understand that fragment should now be natively supported. However I couldn't quickly find the correct syntax for it.

Example of what I'm looking for:

<fragment>
  <button label="foo"/>
  <button label="bar"/>
</fragment>
1

There are 1 best solutions below

0
Peter Lamberg On

Here is the official documentation page on reason-react and fragments.

The syntax for using React fragments in reason-react is this:

<>
  <button label="foo"/>
  <button label="bar"/>
</>

The terse syntax may be easy to miss if you are looking hard for something like <Fragment> (this is what happened to me). I first found the answer in the release notes for version 0.5.0