reactjs / reactjs/react.dev

Change Missing From Changelog: forEach() Loop's `Return` returns to forEach()'s invocation point, not to the calling function.

オープン
#2,732 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
JavaScript
スター
11.8k
フォーク
7.9k
平均マージ
1日 11時間
マージ済み PR(30日)
11

説明

Hey all,

I'm noticing that in upgrading to ReactJS Version 16.12.0 from 16.7.0, the behavior of foreach was changed, so that return returns to where foreach is called, and not the function calling the function containing the foreach. But I don't see this change here:

https://github.com/facebook/react/blob/master/CHANGELOG.md

Basically,

function1() {
	function2();
	console.log("function 1");
}

function2() {
	const arr = ['cool'];
	arr.forEach((var) => {
		return var;
	});
	console.log("function 2");
}

Before 16.12.0, console output was: "function 1", but now it is "function 2; function 1." This change appears to be against MDN documentation and internet consensus: https://stackoverflow.com/questions/34653612/what-does-return-keyword-mean-inside-foreach-function

But it should have been included in the changelog, though I am not seeing it. Let me know if I'm misunderstanding.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

CHANGELOG.md と、issue で参照されている React 16.12.0 の changelog エントリから始めます。リンクされている MDN および Stack Overflow の参照に基づいて、報告された forEach() の動作を検証し、その後 changelog にエントリが不足しているかどうかを判断します。完了とは、報告が検証され、該当する場合に changelog がリリースを正確に反映していることを意味します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, react
領域
documentation
issue の種類
ドキュメント
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。