How do I mark a prop as not required?
Answered
WhyFencePost (Ping Reply) posted this in #help-forum
I have a prop that is not needed, and I need to figure out how to set it as non required:
I don't need the variant prop to be required, only optional, so how do I do that?
function MenuButton({ variant = "normal", size, children } : { variant: "normal" | "main" | "danger" | "disabled", size: "sm" | "lg", children: any }) {I don't need the variant prop to be required, only optional, so how do I do that?
4 Replies
Netherland Dwarf
Is this typescript?
You can use ?
@WhyFencePost (Ping Reply) I have a prop that is not needed, and I need to figure out how to set it as non required:
tsx
function MenuButton({ variant = "normal", size, children } : { variant: "normal" | "main" | "danger" | "disabled", size: "sm" | "lg", children: any }) {
I don't need the variant prop to be required, only optional, so how do I do that?
variant?: "normal" | "main" | "danger" | "disabled"
Answer
thanks