Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent unnecessary wrapping of single line jsx elements (#2183)
When having a single line statement with an import statement everything works as expected. ```jsx import * as React from "react"; <ReactComponent />; ``` However if you remove the import statement, a semicolon `;` appears in the output. We no longer need the explicit import statements as this can be configured globally, and we have an eslint rule requiring us to close every js statement with a semicolon. ```jsx <ReactComponent />; ``` This happens because of the fix/changes done in this issue: #842, which causes every statement starting with JSX to be wrapped in a Fragment. This will cause the semicolon to be added inside the Fragment, and cause it to be rendered. This change causes the examples to only be wrapped in a Fragment if multiple jsx statements are returned on root level of the example by checking for the error before wrapping. Co-authored-by: Thomas Roest <[email protected]>
- Loading branch information