logoESLint React
Rules

unstable-rules-of-props

Enforces the Rules of Props.

This rule is currently in beta and only available in v3.0.0 beta releases.

This rule is experimental and may change in the future or be removed. It is not recommended for use in production code at this time.

Full Name in @eslint-react/eslint-plugin@beta

@eslint-react/unstable-rules-of-props

Full Name in eslint-plugin-react-x@beta

react-x/unstable-rules-of-props

Features

๐Ÿงช

Presets

Rule Details

This rule covers three concerns:

  1. Using conflicting prop combinations.

Common Violations

Using Controlled and Uncontrolled Props Together

Mixing both modes on the same element is a mistake. React will silently ignore the default* prop and may emit a console warning. The element behaves as controlled, which causes confusing bugs when the developer expects the initial value to be respected.

The following prop pairs must not appear together on the same element:

Controlled propUncontrolled prop
valuedefaultValue
checkeddefaultChecked

Invalid

// โŒ 'defaultValue' is ignored because 'value' makes the input controlled.
<input value={name} defaultValue="World" />;
// โŒ 'defaultChecked' is ignored because 'checked' makes the checkbox controlled.
<input type="checkbox" checked={isChecked} defaultChecked />;
// โŒ Order does not matter โ€” the pair is still invalid.
<textarea defaultValue="fallback" value={content} />;
// โŒ Custom components that follow the same pattern are also flagged.
<MyInput value={val} defaultValue="fallback" />;

Valid

// โœ… Controlled input โ€” value is driven by React state.
<input value={name} onChange={(e) => setName(e.target.value)} />;
// โœ… Uncontrolled input โ€” host element manages the value; initial value is provided.
<input defaultValue="World" />;
// โœ… Controlled checkbox.
<input
  type="checkbox"
  checked={isChecked}
  onChange={(e) => setIsChecked(e.target.checked)}
/>;
// โœ… Uncontrolled checkbox with an initial checked state.
<input type="checkbox" defaultChecked />;

Resources

Further Reading

On this page