#func parameter default value

11 messages · Page 1 of 1 (latest)

upbeat stirrup
#

I have a function

export default function NavBar(props: { post }) {...}
#

I want post to to be a boolean and its default value to be true

#

but when I do this I get an error

#

func parameter default value

nocturne bloom
#

The best you can do is function NavBar({ post = true }: { post?: boolean }), pretty sure

upbeat stirrup
# upbeat stirrup

I was looking at it and I just saw I had props as the parameter and the object as the type

#

I was thinking the object was the parameter

#

I can just do this

#

ts infers the type from the default value