How to add jsx-control-statements #7927
-
Clear and concise description of the problemThere is a plugin used in Babel to add control statements (If, etc) namned: jsx-control-statements. Suggested solutionHave a plugin in Vite that does the same work. AlternativeNo response Additional contextNo response Validations
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
It can be achieved by using |
Beta Was this translation helpful? Give feedback.
-
I just wrote a native Vite plugin that solves this issue with react and typescript. It has the If, Choose, When, and Otherwise components from jsx-control-statements (the others couldn't be made due to typescript issues). The plugin does code transformation on those components to turn them into actual ternary operators. Feel free to use it and give any feedback. https://github.com/kirankunigiri/vite-plugin-react-control-statements |
Beta Was this translation helpful? Give feedback.
It can be achieved by using
babel.plugin
options inplugin-react
if you are usingplugin-react
.https://stackblitz.com/edit/vitejs-vite-kaynvt?file=vite.config.js&terminal=dev