チュートリアルをやっていて、いろいろとわからなかった。。。 まずはこれ。
const { isFetching, lastUpdated, items: posts } = postsBySubreddit[selectedSubreddit] || { isFetching: true, items: [] }
少し分解して、
const { isFetching, lastUpdated, items } = { isFetching: true, items: [] } console.log(isFetching) // true console.log(items) // []
これは代入分割というらしい。
そして、次に
const { items: posts } = { items: [] } console.log(posts) // [] console.log(items) // error
“異なる名前を持つ変数への代入"ができるらしい。