-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Description
Hello. Hopefully this is the correct place to ask.
I am trying to use the react/no-multi-comp
rule:
"rules": {
...
"react/no-multi-comp": ["error", {"ignoreStateless": true}]
}
As I understand it, this should NOT allow two components in one file that both use state. For example, I would expect this to fail, but it passes:
import React, { useState } from "react";
const FirstStateful = () => {
let [bool, setBool] = useState("a");
return <button onClick={() => setBool(!bool)}>{String(bool)}</button>;
};
const SecondStateful = () => {
let [counter, setCounter] = useState(1);
return <button onClick={() => setCounter(counter + 1)}>{counter}</button>;
};
const FirstNotStateful = ({ content }) => {
return <p>{content}</p>;
};
const SecondNotStateful = ({ content }) => <p>{content}</p>;
Note that if I change the rule to "react/no-multi-comp": ["error", {"ignoreStateless": false}]
, it does mark everything after the first one as an error.
Additionally, I noticed that there was a recent commit affecting no-multi-comp
, so I cloned eslint & retried this with a local dependency, still no dice.
Metadata
Metadata
Assignees
Labels
No labels