I’m using a primereact component, whose props include a function, and I want to use one of the other props in this function. The overall scheme of things looks like this:
interface Props {
label?: string;
url?: string;
style?: string;
action?: (a: FuncArguments): void;
[key: string]: any;
}
The thing I want to do is this:
const myItem : Props {
label: "AwesomeName",
style: myStyles.ordinaryItem,
action: () => {
someResolver.resolveSomething(this.label);
}
};
Well… this.label
is not accessible, because this
is somehow always undefined and cannot even be cast to Props
.
I’m not too much of a React wiz, or even a JS wiz, so this entire situation is making me a little confused.