DocumentationRulesprefer-shorthand-fragment

prefer-shorthand-fragment

Rule category

Style.

What it does

Enforces the use of shorthand syntax for fragments.

Examples

Failing

import React, { Fragment } from "react";
 
function Example() {
  return <Fragment><button /><button /></Fragment>;
  //       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  //       - Use fragment shorthand syntax instead of 'Fragment' component.
}

Passing

import React from "react";
 
function Example() {
  return <><button /><button /></>;
}