I'm using react 17.0.2 with Typescript. I'm trying to pass setLoading
from the parent component (App
) to the child component (About
) such that the loading state in App
can be set from About
.
interface AboutProps {
setLoading: (arg: boolean | undefined) => void
}
const About: React.FC<AboutProps> = ({ setLoading }) => {
const fields = [
...
];
const { data, loading, error } = useFetch('About', fields);
useEffect(() => setLoading(loading), [loading]);
return (
<div className="aboutComponent">
<div>
<Title title={data.custom_title} />
<Card
text={data.body}
>
<Skills
skills_={data.skills}
skillYears_={data.skill_years}
columns_={data.n_skills_columns}
/>
</Card>
</div>
</div>
);
};
However, ESLint is complaining about missing props validation for setLoading
in line 1. The setLoading
function is passed from the parent component here:
const App = () => {
const [loading, setLoading] = useState<any>(false);
return (
<div>
<About setLoading={setLoading} />
</div>
);
};
I haven't seen this error before and I'm not sure what to do, since I already type the props with AboutProps
interface.