question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

no-undef mark JSX elements as not defined

See original GitHub issue

With

var React =require('react'),
    Router = require('react-router'),
    Route = Router.Route,
    DefaultRoute = Router.DefaultRoute;

at the top and using eslint@0.17.0 and eslint-plugin-react@1.5.0 with
"react/jsx-uses-react": 1, "react/jsx-uses-vars": 1

This works fine.


var routes = React.createClass({
  render: function() {
    return (
      <Route
        name='app'
        path='/'
        handler={ App }>

        <Route
          name='bonfires'
          path='/bonfires/?:bonfires?'
          handler={ Bonfires } />

        <DefaultRoute
          handler={ Bonfires } />
      </Route>
    );
  }
});

But this barphs all over the place

var routes = (
  <Route 
    name='app'
    path='/'
    handler={ App }>

    <Route
      name='bonfires'
      path='/bonfires/?:bonfires?'
      handler={ Bonfires } />

    <DefaultRoute
      handler={ Bonfires } />
  </Route>
);

1__tmux

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

15reactions
r01010010commented, Jan 11, 2017

adding these rules fixed it for me:

"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1
1reaction
cookcccommented, Aug 2, 2021

Official answer is here https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors and it says indeed to add them to globals or to disable the no-undef rule because typescript has already its own checks

overrides: [
    {
      files: ['*.ts', '*.tsx'],
      rules: {
        'no-undef': 0,
      },
    },
  ]
Read more comments on GitHub >

github_iconTop Results From Across the Web

no-undef mark JSX elements as not defined · Issue #19 - GitHub
With var React =require('react'), Router = require('react-router'), Route = Router.Route, DefaultRoute = Router.DefaultRoute; at the top and ...
Read more >
React & Typescript: 'JSX' is not defined no-undef
I am migrating from JS to TS and I get an error when I define the JSX.Element type in my ...
Read more >
'X' is not defined react/jsx-no-undef Error in React | bobbyhadz
The React.js error "X is not defined react/jsx-no-undef" occurs when we forget to import a function, class or a variable in our code...
Read more >
'React' is not defined no-undef - YouTube
Blog Reference : https://progvocab.blogspot.com/2020/01/ react -is- not - defined - no-undef.html.
Read more >
eslint-plugin-react - npm
Start using eslint-plugin-react in your project by running `npm i ... If this isn't set, components wrapped by these functions will be ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found