Comments (9)
You don't import it, because it's a babel plugin. Just install it and reference the plugin in your babel configuration (See https://github.com/AlexGilleran/jsx-control-statements#installation). Then you're all set up and you can use it within your JSX.
from jsx-control-statements.
I use:
"babel": {
"plugins": [
"jsx-control-statements"
]
}
in package.json
And after "npm run start"
it show
"'If' is not defined react/jsx-no-undef"
Also tried name: "babel-plugin-jsx-control-statements"
from jsx-control-statements.
You cannot configure babel via package.json
. Typically you do the configuration in an own file called .babelrc
; of course, there are also different options to configure babel...
Furthermore, if you want to use linting, please read this section: https://github.com/AlexGilleran/jsx-control-statements#linting
from jsx-control-statements.
Also tried to make .babelrc
file in the root folder of the project, and the same result.
{
"plugins": ["jsx-control-statements"]
}
or
{
"plugins": ["babel-plugin-jsx-control-statements"]
}
Read here - http://babeljs.io/docs/usage/babelrc about package.json
Working on Windows
on VisualStudio Code
with default react template.
from jsx-control-statements.
Ah ok, didn't knew about this package.json option. Thanks.
Anyways, the error is produced by your linter. The concrete rule is: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
It means that <If>
is not defined in your file. And this is of course true, since there is no component with the name If
. Jsx-control-statements only transforms component-like structures before react renders them. So to fix this linting issue you need to install an additional plugin: https://github.com/vkbansal/eslint-plugin-jsx-control-statements
Have you configured the jsx-
from jsx-control-statements.
I have this code in project.json
"babel": {
"plugins": [
"jsx-control-statements"
]
},
"eslintConfig": {
"plugins": [
"jsx-control-statements"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"extends": ["plugin:jsx-control-statements/recommended"],
"rules": {
"react/jsx-no-undef": [2, { "allowGlobals": true }]
}
}
And both modules babel-plugin-jsx-control-statements
and eslint-plugin-jsx-control-statements
installed. And it shows the same error and result.
Have no idea what i am doing wrong...
from jsx-control-statements.
default react template.
Do you mean you're using Create React App? Unfortunately this doesn't let you override eslint properly so it doesn't work with JSX Control Statements :(
from jsx-control-statements.
Thank you.
Strange, i don't understand. I thought that this template is like just a directory with subdirectories and files, and if i want I can modify anything in it... I thought that there is an ability to change anything in project and it`s configuration. Maybe something is hardcoded (somewhere) in this template so I can not modify it to make it work?
from jsx-control-statements.
Oh. Now i understand Create React Template has config files in modules, so if i tried to edit them i broke updating (eject).
from jsx-control-statements.
Related Issues (20)
- The control statements don't narrow TypeScript types HOT 1
- TypeScript type for children is missing a render function HOT 1
- TChildren conflicts with ReactNode children HOT 2
- Why do we need ```transform-react-inline-elements``` plugin ?
- Switch-case style control statement HOT 2
- Problem with ./node_modules/tsx-control-statements/components.ts HOT 3
- Typo error HOT 1
- Support babel macros HOT 2
- conditional statements don't work unless wrapped in brackets. is this supposed to happen? HOT 1
- Not working with laravel-mix with webpack config
- Can you provide plugins for swc HOT 1
- Can you provide a version based on swc core? HOT 1
- Uncaught ReferenceError: For is not defined HOT 5
- Not working with create-react-app HOT 7
- If is not defined HOT 4
- App breaks if i try to directly access the url - With Error - Choose is not defined HOT 1
- React-Native:Installation-Guide HOT 2
- last published version is 3 years old HOT 2
- ESLint autofix HOT 2
- Undefined is not a function with new JSX transform with react 17 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsx-control-statements.