reactjs / reactjs/react.dev

[Question] about "._owner.alternate"

Open
#1,919 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
11.8k
Forks
7.9k
Avg merge
1d 11h
Merged PRs (30d)
11

Description

It seems that in react@16 every React element children contains cyclic property ._owner.alternate.alternate.alternate.alternate....

image

So it is easy to cause "Maximum call stack exceeded" error when developer compares props.children in deep way(like deep-equal).

This caused bugs for community libraries like react-helmet:
https://github.com/nfl/react-helmet/issues/441

I am extremely curious about:
Why React has _owner.alternate, and what it stands for?
As it is named as “_owner”, could it be better if we make “owner” not enumerable?

I tried to search source code and but still can’t find any clue.

Thanks in advance.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file or test is named. Begin by tracing the React 16 source that creates element children and the _owner.alternate chain, then review the linked react-helmet issue 441. Done means documenting what _owner.alternate represents and resolving whether the enumerable-owner concern requires a documented change.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.