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.

'className' instead of 'class' within JSX markup

See original GitHub issue

Hi,

Is there anyway we could add a rule that lets you lint for the use of the ‘class’ field when it should be ‘className’?

ex:

render () {
    console.log('Render');
    return (
        <div key={this.props.id} class='bookListItem'>
            <p>{this.props.title}</p>
            <p>{this.props.description}</p>
        </div>
    );
  }

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ljharbcommented, Sep 18, 2018

Yes, if you want a rule to forbid invalid html props based on the element type, we’d need a different rule.

0reactions
Primajincommented, Sep 19, 2018

Cool, opened #1990

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why React uses className over class attribute
Explanation: The only reason behind the fact that it uses className over class is that the class is a reserved keyword in JavaScript...
Read more >
class vs className in React 16 - Stack Overflow
class is a keyword in javascript and JSX is an extension of javascript. That's the principal reason why React uses className instead of ......
Read more >
'className' instead of 'class' within JSX markup #186 - GitHub
This is an error, but no-unknown-property won't catch it because it isn't a DOM element. Is there a blanket way to flag all...
Read more >
Why do I have to use 'className' instead of 'class' in ReactJs ...
JSX is just the description of HTML in strings, with curly braces {} to embed JS values. Because it is parsed by JavaScript,...
Read more >
class vs className - Learn React - Codecademy
This is because JSX gets translated into JavaScript, and class is a reserved word in JavaScript. When JSX is rendered, JSX ...
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