TypeScript + Reactアプリケーションで二重ループを回していましたが、
TypeError: Cannot read property '0' of undefined
が出ました。
let のスコープの問題かと思って、_w
を設定しましたが、同じ用にエラーが出ます
解決方法が知りたいです
const createWordList = (dict: string[]) => { const res = []; let l = 65; let _w = 0; while (l < 65 + 26 && _w < dict.length) { const letter = String.fromCharCode(l); let w = _w; // insert heading letter res.push(<Heading key={l}>{letter}</Heading>); while (dict[w][0].toUpperCase() == letter && w < dict.length) { console.log(dict[w]); res.push(<div>{dict[w++]}</div>); } _w = w; l++; } return res; };
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。