const pos = todos.indexOf(todo);としてはいけないのでしょうか?

2021年9月1日
ユーザー

試してみたのですが、
const todos = this.state.todos.slice();
const pos = todos.indexOf(todo);
上記の様な記載としても動作的に問題がなかったです。
認識としては
const pos = this.state.todos.indexOf(todo);
とするとApp Componentでのstateの配列を参照している認識で、
const pos = todos.indexOf(todo);
とすると直前にコピーしたconst todos = this.state.todos.slice();を参照している
認識になります。
認識に齟齬があれば教えて頂ければ幸いです。
よろしくお願いします。

この回答を見るにはプレミアムサービスへの登録が必要です

プレミアムサービスとは?