Skip to content

Commit eec6fb3

Browse files
samwgoldmanSam Goldman
authored andcommitted
Add createContext, createRef to default export object as well
Summary: We do a thing where we export var all the React functions, but we also export default an object with them all. This makes `import React from 'react'` as well as `import * as React from 'react'` work. We added createContext and createRef recently, but neglected to add them to the default export object. This diff makes the new APIs available in the same way the old APIs have been. Reviewed By: avikchaudhuri Differential Revision: D7526419 fbshipit-source-id: ee48c1e97214a24d587762b420e872a2433e1a19
1 parent 2819e49 commit eec6fb3

File tree

7 files changed

+166
-158
lines changed

7 files changed

+166
-158
lines changed

lib/react.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,11 @@ declare module react {
261261
+version: typeof version,
262262
+checkPropTypes: typeof checkPropTypes,
263263
+createClass: typeof createClass,
264+
+createContext: typeof createContext,
264265
+createElement: typeof createElement,
265266
+cloneElement: typeof cloneElement,
266267
+createFactory: typeof createFactory,
268+
+createRef: typeof createRef,
267269
+isValidElement: typeof isValidElement,
268270
+Component: typeof Component,
269271
+PureComponent: typeof PureComponent,

tests/getters_and_setters/getters_and_setters.exp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,8 @@ References:
489489
react.js:17:13
490490
17| (<Example a="bad" />); // error: number ~> string
491491
^^^^^ [1]
492-
<BUILTINS>/react.js:310:36
493-
310| number: React$PropType$Primitive<number>;
492+
<BUILTINS>/react.js:312:36
493+
312| number: React$PropType$Primitive<number>;
494494
^^^^^^ [2]
495495

496496

@@ -506,8 +506,8 @@ References:
506506
react.js:18:20
507507
18| (<Example a={0} c={0} />); // error: number ~> string
508508
^ [1]
509-
<BUILTINS>/react.js:312:36
510-
312| string: React$PropType$Primitive<string>;
509+
<BUILTINS>/react.js:314:36
510+
314| string: React$PropType$Primitive<string>;
511511
^^^^^^ [2]
512512

513513

tests/new_react/new_react.exp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ Cannot assign `this.props.x` to `_` because number [1] is incompatible with stri
189189
^^^^^^^^^^^^
190190

191191
References:
192-
<BUILTINS>/react.js:310:36
193-
310| number: React$PropType$Primitive<number>;
192+
<BUILTINS>/react.js:312:36
193+
312| number: React$PropType$Primitive<number>;
194194
^^^^^^ [1]
195195
classes.js:57:12
196196
57| var _: string = this.props.x;
@@ -388,8 +388,8 @@ Cannot assign `this.props.z` to `qux` because:
388388
^^^^^^^^^^^^
389389

390390
References:
391-
<BUILTINS>/react.js:310:36
392-
310| number: React$PropType$Primitive<number>;
391+
<BUILTINS>/react.js:312:36
392+
312| number: React$PropType$Primitive<number>;
393393
^^^^^^ [1]
394394
new_react.js:19:18
395395
19| var qux: string = this.props.z;
@@ -405,8 +405,8 @@ Cannot assign `this.props.x` to `w` because string [1] is incompatible with numb
405405
^^^^^^^^^^^^
406406

407407
References:
408-
<BUILTINS>/react.js:312:36
409-
312| string: React$PropType$Primitive<string>;
408+
<BUILTINS>/react.js:314:36
409+
314| string: React$PropType$Primitive<string>;
410410
^^^^^^ [1]
411411
new_react.js:20:15
412412
20| var w:number = this.props.x;
@@ -439,8 +439,8 @@ References:
439439
new_react.js:29:23
440440
29| var element = <C x = {0}/>;
441441
^ [1]
442-
<BUILTINS>/react.js:312:36
443-
312| string: React$PropType$Primitive<string>;
442+
<BUILTINS>/react.js:314:36
443+
314| string: React$PropType$Primitive<string>;
444444
^^^^^^ [2]
445445

446446

@@ -545,8 +545,8 @@ Cannot assign `this.props.x` to `a` because:
545545
^^^^^^^^^^^^
546546

547547
References:
548-
<BUILTINS>/react.js:312:36
549-
312| string: React$PropType$Primitive<string>;
548+
<BUILTINS>/react.js:314:36
549+
314| string: React$PropType$Primitive<string>;
550550
^^^^^^ [1]
551551
props.js:14:16
552552
14| var a: number = this.props.x; // error
@@ -582,8 +582,8 @@ Cannot assign `this.props.z` to `c` because:
582582
^^^^^^^^^^^^
583583

584584
References:
585-
<BUILTINS>/react.js:310:36
586-
310| number: React$PropType$Primitive<number>;
585+
<BUILTINS>/react.js:312:36
586+
312| number: React$PropType$Primitive<number>;
587587
^^^^^^ [1]
588588
props.js:16:16
589589
16| var c: string = this.props.z; // error
@@ -604,14 +604,14 @@ References:
604604
props.js:20:29
605605
20| var element = <TestProps x={false} y={false} z={false} />; // 3 errors
606606
^^^^^ [1]
607-
<BUILTINS>/react.js:312:36
608-
312| string: React$PropType$Primitive<string>;
607+
<BUILTINS>/react.js:314:36
608+
314| string: React$PropType$Primitive<string>;
609609
^^^^^^ [2]
610610
props.js:20:49
611611
20| var element = <TestProps x={false} y={false} z={false} />; // 3 errors
612612
^^^^^ [3]
613-
<BUILTINS>/react.js:310:36
614-
310| number: React$PropType$Primitive<number>;
613+
<BUILTINS>/react.js:312:36
614+
312| number: React$PropType$Primitive<number>;
615615
^^^^^^ [4]
616616

617617

@@ -668,8 +668,8 @@ References:
668668
props2.js:9:41
669669
9| getInitialState: function(): { bar: number } {
670670
^^^^^^ [1]
671-
<BUILTINS>/react.js:312:36
672-
312| string: React$PropType$Primitive<string>;
671+
<BUILTINS>/react.js:314:36
672+
314| string: React$PropType$Primitive<string>;
673673
^^^^^^ [2]
674674
props2.js:15:42
675675
15| return <C {...this.state} foo = {0} />;
@@ -700,12 +700,12 @@ Cannot get `React.PropTypes.string.inRequired` because property `inRequired` is
700700
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
701701

702702
References:
703-
<BUILTINS>/react.js:286:39
703+
<BUILTINS>/react.js:288:39
704704
v
705-
286| type ReactPropsChainableTypeChecker = {
706-
287| isRequired: ReactPropsCheckType;
707-
288| (props: any, propName: string, componentName: string, href?: string): ?Error;
708-
289| };
705+
288| type ReactPropsChainableTypeChecker = {
706+
289| isRequired: ReactPropsCheckType;
707+
290| (props: any, propName: string, componentName: string, href?: string): ?Error;
708+
291| };
709709
^ [1]
710710

711711

0 commit comments

Comments
 (0)