The array
const props: NavButtonProps[] = [
{
text: "Home",
url: "teste"
},
{
text: "Services",
url: "teste"
},
{
text: "projects",
url: "teste"
}
]
where the method map is used
const NavButtonWrapper = (buttons: NavButtonProps[]): ReactElement => {
return (
<div className="flex space-x-16">
{ buttons.map((button) => { return (<NavButton {...button}/>)})}
</div>
)
}
I’ve already seen some cases where it works, but i don’t know why in my code it returns buttons.map is not a function
3
Answers
It’s just a syntax error, you can try removing () after return statement ,
Find the below code
{buttons.map((button) => {
})}
Thanks, hope this help.
try it this way:
Destructure the props to access the buttons prop.