@samitouri / QOS-React-2 / commits / 786186c692

[Flare] createInitialState -> getInitialState (#16051)

Dominic Gannaway committed Jul 4, 2019 at 18:06 UTC 786186c6928f729c0fc0316023da071b1cceea13
13 files changed +19 -17
packages/react-dom/src/events/__tests__/DOMEventResponderSystem-test.internal.js
+3 -3
@@ -20,7 +20,7 @@ const DiscreteEvent = 0;
20 function createReactEventComponent({
21 targetEventTypes,
22 rootEventTypes,
23 - createInitialState,
23 + getInitialState,
24 onEvent,
25 onEventCapture,
26 onRootEvent,
@@ -34,7 +34,7 @@ function createReactEventComponent({
34 displayName: 'TestEventComponent',
35 targetEventTypes,
36 rootEventTypes,
37 - createInitialState,
37 + getInitialState,
38 onEvent,
39 onEventCapture,
40 onRootEvent,
@@ -596,7 +596,7 @@ describe('DOMEventResponderSystem', () => {
596
597 const EventComponent = createReactEventComponent({
598 targetEventTypes: [],
599 - createInitialState: () => ({
599 + getInitialState: () => ({
600 incrementAmount: 5,
601 }),
602 onUnmount: (context, props, state) => {
packages/react-events/README.md
+1 -1
@@ -48,7 +48,7 @@ type CustomEvent = {
48 }
49 ```
50
51 -### createInitialState?: (props: null | Object) => Object
51 +### getInitialState?: (props: null | Object) => Object
52
53 The initial state of that the Event Component is created with.
54
packages/react-events/src/dom/Drag.js
+1 -1
@@ -88,7 +88,7 @@ function dispatchDragEvent(
88 const DragResponder: ReactDOMEventResponder = {
89 displayName: 'Drag',
90 targetEventTypes,
91 - createInitialState(): DragState {
91 + getInitialState(): DragState {
92 return {
93 dragTarget: null,
94 isPointerDown: false,
packages/react-events/src/dom/Focus.js
+1 -1
@@ -221,7 +221,7 @@ const FocusResponder: ReactDOMEventResponder = {
221 displayName: 'Focus',
222 targetEventTypes,
223 rootEventTypes,
224 - createInitialState(): FocusState {
224 + getInitialState(): FocusState {
225 return {
226 focusTarget: null,
227 isFocused: false,
packages/react-events/src/dom/FocusScope.js
+1 -1
@@ -50,7 +50,7 @@ const FocusScopeResponder: ReactDOMEventResponder = {
50 displayName: 'FocusScope',
51 targetEventTypes,
52 rootEventTypes,
53 - createInitialState(): FocusScopeState {
53 + getInitialState(): FocusScopeState {
54 return {
55 nodeToRestore: null,
56 currentFocusedNode: null,
packages/react-events/src/dom/Hover.js
+1 -1
@@ -274,7 +274,7 @@ function isEmulatedMouseEvent(event, state) {
274 const HoverResponder: ReactDOMEventResponder = {
275 displayName: 'Hover',
276 targetEventTypes,
277 - createInitialState() {
277 + getInitialState() {
278 return {
279 isActiveHovered: false,
280 isHovered: false,
packages/react-events/src/dom/Press.js
+1 -1
@@ -618,7 +618,7 @@ function handleStopPropagation(
618 const PressResponder: ReactDOMEventResponder = {
619 displayName: 'Press',
620 targetEventTypes,
621 - createInitialState(): PressState {
621 + getInitialState(): PressState {
622 return {
623 activationPosition: null,
624 addedRootEvents: false,
packages/react-events/src/dom/Scroll.js
+1 -1
@@ -131,7 +131,7 @@ function dispatchEvent(
131 const ScrollResponder: ReactDOMEventResponder = {
132 displayName: 'Scroll',
133 targetEventTypes,
134 - createInitialState() {
134 + getInitialState() {
135 return {
136 direction: '',
137 isTouching: false,
packages/react-events/src/dom/Swipe.js
+1 -1
@@ -92,7 +92,7 @@ type SwipeState = {
92 const SwipeResponder: ReactDOMEventResponder = {
93 displayName: 'Scroll',
94 targetEventTypes,
95 - createInitialState(): SwipeState {
95 + getInitialState(): SwipeState {
96 return {
97 direction: 0,
98 isSwiping: false,
packages/react-events/src/rn/Press.js
+1 -1
@@ -506,7 +506,7 @@ const PressResponder: ReactNativeEventResponder = {
506 targetEventTypes,
507 allowEventHooks: true,
508 allowMultipleHostChildren: false,
509 - createInitialState(): PressState {
509 + getInitialState(): PressState {
510 return {
511 activationPosition: null,
512 activePointerId: null,
packages/react-reconciler/src/ReactFiberCompleteWork.js
+3 -2
@@ -1142,8 +1142,9 @@ function completeWork(
1142 getComponentName(workInProgress.type),
1143 );
1144 }
1145 - if (responder.createInitialState !== undefined) {
1146 - responderState = responder.createInitialState(newProps);
1145 + const getInitialState = responder.getInitialState;
1146 + if (getInitialState !== undefined) {
1147 + responderState = getInitialState(newProps);
1148 }
1149 eventComponentInstance = workInProgress.stateNode = createEventComponentInstance(
1150 workInProgress,
packages/react-reconciler/src/ReactFiberEvents.js
+3 -2
@@ -60,8 +60,9 @@ export function updateEventComponentInstance<T, E, C>(
60 }
61 if (currentEventComponentInstanceIndex === events.length) {
62 let responderState = null;
63 - if (responder.createInitialState !== undefined) {
64 - responderState = responder.createInitialState(props);
63 + const getInitialState = responder.getInitialState;
64 + if (getInitialState !== undefined) {
65 + responderState = getInitialState(props);
66 }
67 const eventComponentInstance = createEventComponentInstance(
68 ((currentlyRenderingFiber: any): Fiber),
packages/shared/ReactTypes.js
+1 -1
@@ -94,7 +94,7 @@ export type ReactEventResponder<T, E, C> = {
94 displayName: string,
95 targetEventTypes?: Array<T>,
96 rootEventTypes?: Array<T>,
97 - createInitialState?: (props: Object) => Object,
97 + getInitialState?: (props: Object) => Object,
98 allowMultipleHostChildren: boolean,
99 allowEventHooks: boolean,
100 onEvent?: (event: E, context: C, props: Object, state: Object) => void,