'How do you handle 'no-unused-prop-types' in functions that vary in which props are used?
Say you have the following props list.
interface Props {
x?: string;
y?: string;
z?: string;
}
And you want to use them in functions like this:
const FirstFunc= ({ x }: Props ) => { // code that only uses prop x };
const SecondFunc= ({ x, y }: Props ) => { // code that only uses prop x and y };
const ThirdFunc= ({ x, z }: Props ) => { // code that only uses prop x and z };
const FourthFunc= ({ x, y, z }: Props ) => { // code that uses all three props. };
As it stands, because of eslint's "no-unused-prop-types" rule, it throws an error as the result of ALL of the props not being used in each function, even though they are marked as optional. Is there a way to resolve this? Would it be better to just have the functions take typed parameters instead of utilizing a props interface? Or am I just completely misunderstanding the purpose of creating a Prop type?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
