I have one React Component in which I am using useState hook. I tried to set value to general onClick of menu item.
const [value,setValue]= useState("");
<Menu.Item onClick={()=>setValue("general"))>
</Menu.Item>
In another file I am passing that value.
<ChannelForm
value={value}
/>
I am using TypeScript. Have declared prop type definition as
value?: "general" | "competitive" | "social" | "podcast";
But while passing value as a props I am getting above error.
Just to clarify - are you using an interface? See this question: Using state in react with TypeScript, for more on that.
If that doesn't help, the problem could be typescript thinks it's being passed a null value. To fix that you can use the non-null assertion operator. Read more about that in this answer: Typescript: Type 'string | undefined' is not assignable to type 'string'
If neither of those helps, let me know!