APIリクエストとグリッドレンダリングの両方のコードを作成しましたが、2つの方法を組み合わせる方法は混乱しています反応環境。助言がありますか?APIリクエストとグリッドレンダリングを組み合わせようとしています
(これは反応-axiosを使用している)
<Request
method="get", /* get, delete, head, post, put and patch - required */
url="http://coincap.io/front", /* url endpoint to be requested - required */
debounce={50} /* minimum time between requests events - optional */
onSuccess={(response)=>{}} /* called on success of axios request - optional */
onError=(error)=>{} /* called on error of axios request - optional */
/>
私はこのハードコーディングされたデータを削除し、データをグリッドをレンダリングするために探していますCoinCap.io
// Grid data as an array of arrays
const list = [
['Brian Vaughn', 'Software Engineer', 'San Jose', 'CA', 95125 /* ... */ ]
// And so on...
];
function cellRenderer ({ columnIndex, key, rowIndex, style }) {
return (
<div
key={key}
style={style}
>
{list[rowIndex][columnIndex]}
</div>
)
}
ReactDOM.render(
<Grid
cellRenderer={cellRenderer}
columnCount={list[0].length}
columnWidth={150}
height={300}
rowCount={list.length}
rowHeight={60}
width={700}
/>,
document.getElementById('root')
);
へのAPI呼び出しから引き出さ
素晴らしいドニー。私はライフサイクルの手法を見てきましたが、それについてはあまり学んでいないので、さらに詳しく見ていきます。 – loop13side7
Donny、ライフサイクルメソッド内でAPIコールを作成すると、どうなるでしょうか? – loop13side7