ESLint is giving me this error on a react project.
ESLint - Component should be written as a pure function (react prefer/stateless function)
It poi
If all you're doing is rendering a jsx template, and not declaring state with constructor(props)
, then you should write your component as a pure function of props, and not use the class
keyword to define it.
ex.
export const myComponent = () => (
// jsx goes here
);
You will get this error only when your class does not have any life cycle method or constructor. To solve this either you have to disable the lint property or make it as a pure function or create constructor for the class.