Eslint-plugin-react: style-prop-object does not allow null

Created on 9 Sep 2016  路  7Comments  路  Source: yannickcr/eslint-plugin-react

I use style variables that are conditionally set as objects only when required, and AFAIK it's valid to provide null props to React.

bug

All 7 comments

indeed, null and undefined should both be accepted.

This might be worth looking into at the same time as #809

cc @petersendidit

@ljharb This fails in 6.9.0 on an edge case of an explicit null variable:

let style = null;
<div style={style}></div>

I dropped the unnecessary = null in my own code, so it's not an issue for me, but I thought I'd make a note of it just in case.

@vdh fails in what way?

@ljharb Line 37 doesn't have the same null check as line 72, so it gives a Style prop value must be an object error.

I was also able to get a test failure by duplicating this existing test and adding = null to it.

@vdh thanks, this is now fixed in latest master.

Was this page helpful?
0 / 5 - 0 ratings