I'm running into an unexpected error while writing JSX functional component with NextJS. As soon as I insert a different component in my code, it would return "Unexpected token" error.
I've tried adding {}, (), change to function Entries(){}, move the mockList into the function, but none worked. I'm still receiving this error once I place another component inside the return.
Function component Entries
import Entry from './Entry'
import Detail from './Detail'
const mockList = [
{ title: "Subway"},
{ title: "Yokohama"},
{ title: "Tokyo Station"},
{ title: "Shibuya"},
{ title: "Shinjuku"},
]
const Entries = () => {
return (
mockList.map(list =>
<Entry title={list.title} />
)
)
}
export default Entries
as soon as I changed Entries to
const Entries = () => {
return (
mockList.map(list =>
<Entry title={list.title} />
)
<Detail />
)
}
The error will pop up.
Any suggestion on how to fix this problem? It's been frustrating not to be able to continue with this unexpected error.
I'm writing functional component as a practice to use React Hooks down the road in this app.