Next map
Answered
Blue orchard bee posted this in #help-forum
Blue orchard beeOP
Is this fine? bc is not working :
{links.map(({label,value})=>{
<Link className="navbar__link relative" href={value}>
a{label}
</Link>
})}
{links.map(({label,value})=>{
<Link className="navbar__link relative" href={value}>
a{label}
</Link>
})}
Answered by riský
you should add key to the unique link element: https://legacy.reactjs.org/docs/lists-and-keys.html#keys (and also follow the correct way of doing map - ie implicit return)
13 Replies
Blue orchard beeOP
you should add key to the unique link element: https://legacy.reactjs.org/docs/lists-and-keys.html#keys (and also follow the correct way of doing map - ie implicit return)
Answer
Somali
You’re missing an explicit return, you’ll need it whenever you use the curly braces {}. Try this instead:
{links.map(({ label, value }) => (
<Link className="navbar__link relative" href={value}>
{label}
</Link>
))}@Somali You’re missing an explicit return, you’ll need it whenever you use the curly braces {}. Try this instead:
{links.map(({ label, value }) => (
<Link className="navbar__link relative" href={value}>
{label}
</Link>
))}
dont forget the
key in this example, but other than that, but you are otherwise very correct (as the jsx isn't being used)and slight formatting recommendation for both of you, you can style codeblocks
```jsx
export default function Component() {
return (
<h1>Hello 👋</h1>
)
}
```
turns into:
```jsx
export default function Component() {
return (
<h1>Hello 👋</h1>
)
}
```
turns into:
export default function Component() {
return (
<h1>Hello 👋</h1>
)
}Blue orchard beeOP
Thanks guys, now it works!
I have another question, how do i redirect a user on success of a function? like redirect("/")? bc is not working
you use nextjs's
useRouter and .pushBlue orchard beeOP
Oh okay, i ll try that thanks
@Blue orchard bee Thanks guys, now it works!
*you should mark this thread as [solved](https://canary.discord.com/channels/752553802359505017/1162045067737972756/1162045073886822450) then 🙂 *
i meant the bot command (on message) btw - i know it isn't very normal tho
edit: i just did it