Using boolean-value of attributes in JSX

You can just omit the value assignment; the attribute will be assigned a value of true by default.

Instead of doing any of:

<input data-enable-time=true />
<input data-enable-time="true" />
<input data-enable-time={true} />

Do:

<input data-enable-time />

This approach avoids the warning Value must be omitted for boolean attributes [react/jsx-boolean-value] when the code is linted via eslint-plugin-react. (See: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md)

Leave a Comment