flarum / framework

Simple forum software for building great communities.
http://flarum.org/
6.39k stars 834 forks source link

[Webpack config] Add support for Mithril fragments within JSX #2711

Closed davwheat closed 3 years ago

davwheat commented 3 years ago

Bug Report

Current Behavior In JSX, use of <></> is synonymous of Fragment vnodes. It'd be great to have support for this within Flarum extensions.

Currently we can create fragments using [], but having different syntaxes can lead to being confusing. In my opinion, we should follow the general consensus throughout JSX-using libraries.

Solution

At a glace, we should be able to add this by modifying the webpack config to include pragmaFrag: 'm.fragment' alongside the existing pragma: 'm'. This is explained one scroll-click up from this heading: https://babeljs.io/docs/en/babel-plugin-transform-react-jsx/#installation

Steps to Reproduce

  1. Attempt to render a component wrapped in <>{...}</>
  2. See error in console that "React is not defined"
askvortsov1 commented 3 years ago

Huh, I did not know this existed... Cool!