17

I can not remove following warning in react code. "Attribute className is not allowed here".

  • Warning in PhpStorm

warning in PhpStorm

  • Unknown HTML tag attribute can not be set to camelcase only lower case is saved, and turning the check off is not helping.

Unknown HTML tag attribute can not be set to camelcase only lower case is saved, and turning the check off is not helping

  • Settings in Languages & Frameworks > JavaScript > Libraries

Settings in Languages & Frameworks > JavaScript > Libraries

Can you help me I have warnings for every attribute in jsx. Editor is set jsx harmony.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Marcel Mandatory
  • 1,447
  • 13
  • 25

4 Answers4

19

My problem with warnings in jsx was solved by instaling React-Template plugin.

React-Templates

Marcel Mandatory
  • 1,447
  • 13
  • 25
  • 1
    Worked for me too... Strange, I didn't think I needed this plugin as it provides templates - it's not supposed to do the JSX integration into IntelliJ. I would expect that to be in a React/JSX plugin or something. Oh well. – Gilad Barner Jul 07 '16 at 11:48
5

You should add Reactjs library.

Using Reactjs in JavaScript and TypeScript

In my case, I've just added Reactjs support for TypeScript:

Languages & Frameworks / JavaScript / Libraries / Download

0xCursor
  • 2,242
  • 4
  • 15
  • 33
  • I had a similar problem like the asker after updating to IntelliJ 2016.3 - the values of the classNames were marked as errors. Tried your solution but it didn't help - isn't _"react-DefinitelyTyped"_ supposed to fix just type erros, i.e. if you're using TypeScript? – Gilad Barner Dec 29 '16 at 13:33
4

I'm a little late on the scene but performing Invalidate Caches/Restart... solved the issue (after switching to JSX Harmony).

Wheeler
  • 454
  • 5
  • 17
  • It is possible that this issue was addressed in minor releases of PhpStorm. During the time of asking the question switching to JSX Harmony and Cache invalidation did not help to solve the issue. Thanks for viable way of solving the issue. – Marcel Mandatory Jul 08 '16 at 07:26
  • Hah, something happened while writing code and the warnings started appearing. After invalidating the caches... the warnings went away! – gustavohenke Sep 23 '16 at 17:19
2

Had a similar problem like the asker - after updating to IntelliJ 2016.3, the values of the classNames were marked as errors (not the "className" attribute itself, but it's similar to what he had).

My solution was to select "Uninject language or reference" from the little lightbulb that appears when you put your cursor on the error:

enter image description here

Have no idea why it works.

Couldn't find any decent React/JSX plugins for Intellij either, except from the above mentioned "React-Templates" which did wonders in the past.

But it seems Intellij's native (I guess) support for JSX & React is not bad, except for annoying things like this.

Gilad Barner
  • 721
  • 8
  • 15