Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for the experimental syntax 'jsx' isn't currently enabled #761

Open
fasenderos opened this issue Jul 3, 2021 · 3 comments
Open

Comments

@fasenderos
Copy link

I have installed availity with yarn add @availity/form @availity/yup yup and imported with

import { FormGroup, Form, Input } from "@availity/form";
import "@availity/yup";
import * as yup from "yup";
...

 <Form
        initialValues={{
          hello: "",
        }}
        onSubmit={() => ({})}
        validationSchema={yup.object().shape({
          hello: yup.string().isRequired(true, "This Field is Required."),
        })}
      >
   <FormGroup for="hello">
      <Label for="hello">Hello Field</Label>
      <Input name="hello" />
   </FormGroup>
</Form>

I get this error even though I didn't import Checkbox on this components

./node_modules/@availity/form/src/Checkbox.js
SyntaxError: C:\Users\....\myproject\node_modules\@a
vaility\form\src\Checkbox.js: Support for the experimental syntax 'jsx' isn't cu
rrently enabled (29:5):

  27 |
  28 |   return (
> 29 |     <FormGroup
     |     ^
  30 |       for={inputId}
  31 |       className={groupClassName}
  32 |       check

Add @babel/preset-react (https://git.io/JfeDR) to the 'presets' section of your
Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://git.io/vb4y
A) to the 'plugins' section to enable parsing.

I have tried to add to babel.config.json the following options:

{
  "presets": ["@babel/preset-env", "@babel/preset-react"],
  "plugins": ["@babel/plugin-syntax-jsx"]
}
@LMarlett
Copy link

LMarlett commented Jul 6, 2021

Im also looking for a solution for this error

@DXAizpiri
Copy link

Hello! Any progress on this? I am experiencing the same error when I have started trying to migrate from the old availity-reacstrap-validation library to this one, as commented by @fasenderos. I also tried adding the preset to babel.config.json and did a test with .babelrc as well with no luck ...

I realized that the problem was also reported on stackoverflow 4 months ago (and it was opened here since a month and a half) ... So I am worried if someone is going to get rid of it or maybe it was already solved in another thread / theme?
Thanks in advance!
https://stackoverflow.com/questions/67994385/using-availity-with-react-scripts-support-for-the-experimental-syntax-jsx-i

@jordan-a-young
Copy link
Member

I believe this issue can be fixed in one of two ways. I'm not sure which, but you can try both.

The first is make sure you are using babel-loader with your webpack config, and that it is looking for js and jsx extensions. Here is how we handle it.

The other thing that could help is to make sure you are using babel-preset-react-app. We use it this way

I'm not an expert on this, but all of our apps at Availity use those settings and we do not have any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants