Next.js Discord

Discord Forum

Do i need to always use function declaration in next js routes?

Answered
Raspberry Horntail posted this in #help-forum
Open in Discord
Raspberry HorntailOP
if i write routes in function expression example
}
const FirstBlog = ({params}:{params:{slug:string[]}}) =>{
  return <div></div>
}

If i write like this i have warning in terminal
Answered by joulev
oh i see, this is new. in that case you can use
const FirstBlog = ({params}:{params:{slug:string[]}}) =>{
  return <div></div>
}
FirstBlog.displayName = "FirstBlog"

but yeah, just use the function syntax
View full answer

4 Replies

@joulev what warning is it? that syntax should be fine
Raspberry HorntailOP
Your React component is an anonymous function.
@Raspberry Horntail Your React component is an anonymous function.
oh i see, this is new. in that case you can use
const FirstBlog = ({params}:{params:{slug:string[]}}) =>{
  return <div></div>
}
FirstBlog.displayName = "FirstBlog"

but yeah, just use the function syntax
Answer