vs codeで以下のエラーが出て、表示されません。
「型 'void' を型 'ReactNode' に割り当てることはできません。」
どの様に直したら良いのでしょうか。
ご教授していただければと存じます。
Next.js, TypeScript
Next.js
1import styles from '../../../styles/four.module.css' 2import Data from '../../Data.json' 3import { useRouter } from 'next/router' 4import Link from 'next/link' 5import Image from 'next/image' 6 7export const Four = () => { 8 9 const router = useRouter() 10 const path = router.pathname 11 12 function List(items:any) { 13 items.map((item:any, index:any) => { 14 <li className={styles.listCard}> 15 <div className={styles.pic}><Image src={"/" + item.pic} alt='#' width={250} height={400} /></div> 16 <div className={styles.textWrapper}> 17 <p>{item.name}</p> 18 <p>{item.country}</p> 19 <p>テスト</p> 20 </div> 21 </li> 22 }) 23 } 24 25 function UpToList() { 26 if(path === "/Oceania") { 27 const Oceania = Data.data.beers.Oceania 28 List(Oceania) 29 } 30 } 31 32 return ( 33 <ul className={styles.listBox}> 34 {UpToList()} //エラーが出ているところ 35 </ul> 36 ) 37}
data.json
1{ 2 "data": { 3 "beers" : { 4 "Oceania" : [ 5 { 6 "name" : "XXXX", 7 "country" : "Australia", 8 "pic" : "xxxx-gold-lager.png", 9 "url" : "http://www.xxxx.com.au/" 10 }, 11 { 12 "name" : "Foster's Lager", 13 "country" : "Australia", 14 "pic" : "Foster'sLager.png", 15 "url" : "https://www.fostersbeer.com/" 16 }, 17 { 18 "name" : "Tooheys New", 19 "country" : "Australia", 20 "pic" : "TooheysNew.png", 21 "url" : "https://www.fostersbeer.com/" 22 }, 23 { 24 "name" : "Steinlager", 25 "country" : "New Zealand", 26 "pic" : "steinlager-classic.png", 27 "url" : "https://www.steinlager.com/" 28 } 29 ] 30 } 31 } 32}

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/05/14 15:01