mirror of
https://github.com/facebook/react.git
synced 2026-02-27 03:07:57 +00:00
Replaced an Update effect in complete phase with a Ref effect
Also removed an unnecessary conditional check and improved a flow cast. Relates originally to PRs #8646 and #8685
This commit is contained in:
@@ -57,7 +57,10 @@ findDOMNode._injectFiber(function(fiber: Fiber) {
|
||||
type DOMContainerElement = Element & { _reactRootContainer: ?Object };
|
||||
|
||||
type Container = Element;
|
||||
type Props = { children ?: mixed };
|
||||
type Props = {
|
||||
autoFocus ?: boolean,
|
||||
children ?: mixed,
|
||||
};
|
||||
type Instance = Element;
|
||||
type TextInstance = Text;
|
||||
|
||||
@@ -105,7 +108,7 @@ function shouldAutoFocusHostComponent(
|
||||
case 'input':
|
||||
case 'select':
|
||||
case 'textarea':
|
||||
return !!(props : any).autoFocus;
|
||||
return !!props.autoFocus;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -223,9 +226,7 @@ var DOMRenderer = ReactFiberReconciler({
|
||||
rootContainerInstance : Container,
|
||||
internalInstanceHandle : Object,
|
||||
) : void {
|
||||
if (shouldAutoFocusHostComponent(type, newProps)) {
|
||||
(domElement : any).focus();
|
||||
}
|
||||
((domElement : any) : HTMLButtonElement | HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement).focus();
|
||||
},
|
||||
|
||||
commitUpdate(
|
||||
|
||||
@@ -39,6 +39,7 @@ var {
|
||||
Fragment,
|
||||
} = ReactTypeOfWork;
|
||||
var {
|
||||
Ref,
|
||||
Update,
|
||||
} = ReactTypeOfSideEffect;
|
||||
|
||||
@@ -233,13 +234,13 @@ module.exports = function<T, P, I, TI, PI, C, CX>(
|
||||
// (eg DOM renderer supports auto-focus for certain elements).
|
||||
// Make sure such renderers get scheduled for later work.
|
||||
if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance)) {
|
||||
workInProgress.effectTag |= Update;
|
||||
markUpdate(workInProgress);
|
||||
}
|
||||
|
||||
workInProgress.stateNode = instance;
|
||||
if (workInProgress.ref) {
|
||||
// If there is a ref on a host node we need to schedule a callback
|
||||
markUpdate(workInProgress);
|
||||
workInProgress.effectTag |= Ref;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user