reactjs / reactjs/react.dev

Deep comparison in PureComponent question

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

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

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

説明

Hello team,

We have a base class for React components that we're beginning to use. It's like PureComponent but does deep comparison of JSON-like values (just objects, arrays, and primitives). The purpose is to avoid re-renders when inputs haven't changed, even when objects/arrays were reconstructed.

import React from 'react';
import { compareObj } from './deepCompare';

export default class PureDeepComponent extends React.Component {
    shouldComponentUpdate(newProps, newState) {
        return !(compareObj(this.props, newProps) && compareObj(this.state, newState));
    }
}

I was surprised that something like this wasn't included in React, and I'm wondering what the team's thoughts are -- was there a good reason for not doing something like this?

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

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

はじめの一歩

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

調査の方向性

ファイル、テスト、エントリーポイントは特定されていません。まず、issue に記載されている PureComponent と shouldComponentUpdate の動作を確認し、次に望ましい結果が React API の機能なのかドキュメントなのかを判断してください。そのスコープと受け入れ基準について合意されるまで、issue は完了していません。

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

評価

技術スタック
javascript, react
領域
frontend
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
18/100

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

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