Skip to content

Commit 414c164

Browse files
Follow the React naming pattern for unstable API (#11)
1 parent 578966c commit 414c164

File tree

7 files changed

+16
-35
lines changed

7 files changed

+16
-35
lines changed

__tests__/Context-test.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
import React from "react";
22
import ReactDOM from "react-dom";
3-
import { Record } from "immutable";
43

5-
import {
6-
ReComponent,
7-
NoUpdate,
8-
Update,
9-
SideEffects,
10-
UpdateWithSideEffects
11-
} from "../src";
4+
import { ReComponent, Update } from "../src";
125

13-
import { click, withConsoleMock } from "./helpers";
6+
import { click } from "./helpers";
147

158
describe("ReComponent", () => {
169
let container;

__tests__/ReComponent-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react";
22
import ReactDOM from "react-dom";
33

4-
import { ReComponent, NoUpdate, Update } from "../src";
4+
import { ReComponent, Update } from "../src";
55

66
import { click, withConsoleMock } from "./helpers";
77

__tests__/ReComponentImmutable-test.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@ import React from "react";
22
import ReactDOM from "react-dom";
33
import { Record } from "immutable";
44

5-
import {
6-
ReComponent,
7-
NoUpdate,
8-
Update,
9-
SideEffects,
10-
UpdateWithSideEffects
11-
} from "../src";
5+
import { ReComponent, Update } from "../src";
126

13-
import { click, withConsoleMock } from "./helpers";
7+
import { click } from "./helpers";
148

159
describe("ReComponentImmutable", () => {
1610
let container;
@@ -26,7 +20,7 @@ describe("ReComponentImmutable", () => {
2620
this.handleClick = () => this.send({ type: "CLICK" });
2721
}
2822

29-
initialImmutableState(props) {
23+
unstable_initialImmutableState(props) {
3024
return State();
3125
}
3226

@@ -40,7 +34,7 @@ describe("ReComponentImmutable", () => {
4034
render() {
4135
return (
4236
<button onClick={this.handleClick}>
43-
You’ve clicked this {this.immutableState.count} times(s)
37+
You’ve clicked this {this.unstable_immutableState.count} times(s)
4438
</button>
4539
);
4640
}

__tests__/RePureComponent-test.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import React from "react";
22
import ReactDOM from "react-dom";
33

4-
import {
5-
RePureComponent,
6-
NoUpdate,
7-
Update,
8-
SideEffects,
9-
UpdateWithSideEffects
10-
} from "../src";
11-
12-
import { click, withConsoleMock } from "./helpers";
4+
import { RePureComponent, Update } from "../src";
5+
6+
import { click } from "./helpers";
137

148
describe("RePureComponent", () => {
159
let container;

__tests__/UpdateTypes-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
UpdateWithSideEffects
1010
} from "../src";
1111

12-
import { click, withConsoleMock } from "./helpers";
12+
import { withConsoleMock } from "./helpers";
1313

1414
describe("UpdateTypes", () => {
1515
let container,

src/re.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function Re(Component) {
3838
};
3939
}
4040

41-
// We allow a hidden `Component#initialImmutableState` option to
41+
// We allow a hidden `Component#unstable_initialImmutableState` option to
4242
// initialize the component state based on a returned Immutable.js record
4343
// type.
4444
//
@@ -52,9 +52,9 @@ export function Re(Component) {
5252
// components state since we don't want to overwrite `Component#state`.
5353
//
5454
// Note that this is unstable API and should not be used.
55-
if (typeof this.initialImmutableState === "function") {
55+
if (typeof this.unstable_initialImmutableState === "function") {
5656
this.state = {
57-
immutableState: this.initialImmutableState(props)
57+
immutableState: this.unstable_initialImmutableState(props)
5858
};
5959

6060
setState = (updater, callback) => {
@@ -66,7 +66,7 @@ export function Re(Component) {
6666
callback
6767
);
6868
};
69-
Object.defineProperty(this, "immutableState", {
69+
Object.defineProperty(this, "unstable_immutableState", {
7070
get: () => this.state.immutableState
7171
});
7272
}

type-definitions/ReComponent.js.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ declare export class ReComponent<
4343

4444
// This type is only used when initialState returns an Immutable.js data type.
4545
// Consider this API unstable.
46-
+immutableState: State;
46+
+unstable_immutableState: $ElementType<State, "immutableState">;
4747
}
4848

4949
declare export class RePureComponent<

0 commit comments

Comments
 (0)