React API should be called with the correct number of arguments

  • REACT_MISMATCHED_COUNT_OF_ARGS
  • Error
  • Medium
  • cwe, react

This rule applies when React API is called with the wrong number of arguments.

Because React API has the specification for its arguments, arguments are useless or cause undefined behavior if the number of arguments does not match.

Noncompliant Code Example

View with compliant examples side by side
import { createRoot } from 'react-dom/client';
import App from './App.jsx';

const root = createRoot(document.getElementById('root'));
root.render(); // REACT_MISMATCHED_COUNT_OF_ARGS alarm because 'render()' takes one argument.

Compliant Code Example

View with noncompliant examples side by side
import { createRoot } from 'react-dom/client';
import App from './App.jsx';

const root = createRoot(document.getElementById('root'));
root.render(<App />);

Version

This rule was introduced in DeepScan 1.27.0.

See

Was this documentation helpful?