-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert "Merge pull request #1399 from aweary/use-react-reconciler-rea… #1778
Conversation
cc @gaearon |
Looks like |
Thanks! Do you mind verifying algorithm against the current one? I don’t think it changed but worth checking. It’s okay if invariants are missing (better than depending on constants). |
@@ -0,0 +1,104 @@ | |||
// Extracted from https://github.com/facebook/react/blob/7bdf93b17a35a5d8fcf0ceae0bf48ed5e6b16688/src/renderers/shared/fiber/ReactFiberTreeReflection.js#L104-L228 | |||
function findCurrentFiberUsingSlowPath(fiber) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this is an improvement - we were locked to v0.7.0 before, and now this is just inlining it. Why can't this be pulled from react-reconciler, or why can't react-reconciler be updated?
I'm all for making changes to make things easier for the react team; but copy-pasting code doesn't seem like a good approach for anyone. |
@gaearon it looks like the algorithm hasn't changed, with the exception (heh) of the invariants. See the diff below. @ljharb I'll let @gaearon answer that, I'm not totally familiar with what problems this is causing for us at Facebook. findCurrentFiberUsingSlowPath Diff1,2c1,2
< function findCurrentFiberUsingSlowPath(fiber) {
< const { alternate } = fiber;
---
> export function findCurrentFiberUsingSlowPath(fiber: Fiber): Fiber | null {
> let alternate = fiber.alternate;
3a4,12
> // If there is no alternate, then we only need to check if it is mounted.
> const state = isFiberMountedImpl(fiber);
> invariant(
> state !== UNMOUNTED,
> 'Unable to find node on an unmounted component.',
> );
> if (state === MOUNTING) {
> return null;
> }
11,13c20,22
< while (true) { // eslint-disable-line
< const parentA = a.return;
< const parentB = parentA ? parentA.alternate : null;
---
> while (true) {
> let parentA = a.return;
> let parentB = parentA ? parentA.alternate : null;
18c27,28
< // If both copies of the parent fiber point to the same child, we can
---
>
> // If both copies of the parent fiber point to the same child, we can
22c32
< let { child } = parentA;
---
> let child = parentA.child;
25a36
> assertIsMounted(parentA);
29a41
> assertIsMounted(parentA);
36c48
< throw new Error('Unable to find node on an unmounted component.');
---
> invariant(false, 'Unable to find node on an unmounted component.');
38c50,51
< if (a.return !== b.return) {
---
>
> if (a.return !== b.return) {
52c65
< let { child } = parentA;
---
> let child = parentA.child;
70c83
< ({ child } = parentB);
---
> child = parentB.child;
86,89c99,103
< if (!didFindChild) {
< throw new Error('Child was not found in either parent set. This indicates a bug ' +
< 'in React related to the return pointer. Please file an issue.');
< }
---
> invariant(
> didFindChild,
> 'Child was not found in either parent set. This indicates a bug ' +
> 'in React related to the return pointer. Please file an issue.',
> );
91a106,111
>
> invariant(
> a.alternate === b,
> "Return fibers should always be each others' alternates. " +
> 'This error is likely caused by a bug in React. Please file an issue.',
> );
92a113,118
> // If the root is not a host container, we're in a disconnected tree. I.e.
> // unmounted.
> invariant(
> a.tag === HostRoot,
> 'Unable to find node on an unmounted component.',
> ); |
I think that we'd need more than a vague "it's causing problems" to justify inlining any dependency. |
I also see that react-reconciler is at v0.12.0 - could we update to that? |
Different adapters (even within 16) would need to depend on different versions. |
That's fine, we already have 16.1, 16.2, and 16.3 adapters, and soon i'll do a breaking change on the 16 adapter to require ^16.4. |
(it'd be great if those requirements were documented in the range for react in peerDependencies in react-reconciler; v0.12.0 claims "^16.0.0") |
Hmm. I see. If you don’t mind bumping majors when there are incompatible internal changes then you could make it work. That said, we still don’t provide guarantees about this package working as intended here. The fact that constants match between |
I think I already tried to explain this in |
I understand that; but I'd still expect the peerDep range to match what it's already compatible with, even if it won't be compatible with newer things - ie, |
The There are no guarantees around compatibility between |
got it, that makes sense. |
So whatever problem this PR is attempting to fix - could we add a test that would fail without this PR? |
ed52726
to
69ccc48
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed; this will be merged as part of #1790.
69ccc48
to
b7c054c
Compare
- [New] Add forwardRef support (#1592, @jquense) - [New] Add Portal support (#1760, #1761, #1772, #1774, @jgzuke) - [New] Add pointer events support (#1753, @ljharb) - [New] Add `displayNameOfNode`, `isValidElementType` (#1701, @jquense) - [New] pass the adapter into `createMountWrapper` (#1592, @jquense) - [Fix] preemptively fix compat with React v16.4.3 (#1790, #1778, @gaearon, @aweary) - [Fix] `shallow`: skip updates when nextState is `null` or `undefined` (#1785, @koba04) - update deps - [meta] ensure a license and readme is present in all packages when published
- [New] Add forwardRef support (#1592, @jquense) - [New] Add Portal support (#1760, #1761, #1772, #1774, @jgzuke) - [New] Add pointer events support (#1753, @ljharb) - [Fix] preemptively fix compat with React v16.4.3 (#1790, #1778, @gaearon, @aweary) - [Fix] `shallow`: prevent rerenders with PureComponents (#1786, @koba04) - [Fix] `shallow`: skip updates when nextState is `null` or `undefined` (#1785, @koba04) - [Fix] `shallow`: `setState` after `setProps` calls `componentWillReceiveProps` (#1779, @peanutenthusiast) - [Fix] `mount`/`shallow`: be stricter on the wrapper’s setState/setProps callback - [Fix] `shallow`/`mount`: improve error message when wrapping invalid elements (#1759, @jgzuke) - update deps - [Refactor] remove most uses of lodash - [meta] ensure a license and readme is present in all packages when published
This reverts commit d60360c, reversing
changes made to bbf39e0.