Skip to content

Commit 1a5d951

Browse files
Remove Unstable Immutable.js API (#17)
This PR removes the unused and unstable Immutable.js helper API. I don't think it works great and I'd rather discourage this pattern.
1 parent 1f64146 commit 1a5d951

File tree

5 files changed

+0
-99
lines changed

5 files changed

+0
-99
lines changed

__tests__/ReComponentImmutable-test.js

Lines changed: 0 additions & 53 deletions
This file was deleted.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"babel-preset-env": "^1.7.0",
1919
"babel-preset-react": "^6.24.1",
2020
"flow-bin": "^0.82.0",
21-
"immutable": "^3.8.2",
2221
"jest": "^23.6.0",
2322
"microbundle": "^0.6.0",
2423
"prettier": "^1.14.3",

src/re.js

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ export function Re(Component) {
2222
}
2323
}
2424

25-
// We might overwrite setState later for the Immutable.js helpers, thus we
26-
// keep a reference to the original method around as well.
27-
const originalSetState = this.setState;
2825
let setState = this.setState;
29-
3026
if (process.env.NODE_ENV !== "production") {
3127
this.setState = () => {
3228
const name = this.displayName || this.constructor.name;
@@ -38,39 +34,6 @@ export function Re(Component) {
3834
};
3935
}
4036

41-
// We allow a hidden `Component#unstable_initialImmutableState` option to
42-
// initialize the component state based on a returned Immutable.js record
43-
// type.
44-
//
45-
// To manage the state, we define a couple of helper methods to make it
46-
// work as a regular Component state must always be a plain JavaScript
47-
// object.
48-
//
49-
// To emulate an Immutable.js object, we use a JavaScript object
50-
// consisting of only one key: `immutableState`. To make the render method
51-
// easier, we also expose `Component#immutableState` to access the
52-
// components state since we don't want to overwrite `Component#state`.
53-
//
54-
// Note that this is unstable API and should not be used.
55-
if (typeof this.unstable_initialImmutableState === "function") {
56-
this.state = {
57-
immutableState: this.unstable_initialImmutableState(props)
58-
};
59-
60-
setState = (updater, callback) => {
61-
originalSetState.call(
62-
this,
63-
(state, props) => ({
64-
immutableState: updater(state.immutableState, props)
65-
}),
66-
callback
67-
);
68-
};
69-
Object.defineProperty(this, "unstable_immutableState", {
70-
get: () => this.state.immutableState
71-
});
72-
}
73-
7437
// Sends an `action` to the reducer. The `reducer` must handle this action
7538
// and return either `NoUpdate()`, `Update(state)`, `SideEffects(fn)`, or
7639
// `UpdateWithSideEffects(state, fn)`.

type-definitions/ReComponent.js.flow

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ declare export class ReComponent<
4040

4141
send(action: Action): void;
4242
createSender<A: Action>(actionType: $ElementType<A, "type">): mixed => A;
43-
44-
// This type is only used when initialState returns an Immutable.js data type.
45-
// Consider this API unstable.
46-
+unstable_immutableState: $ElementType<State, "immutableState">;
4743
}
4844

4945
declare export class RePureComponent<

yarn.lock

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,10 +2048,6 @@ ignore-walk@^3.0.1:
20482048
dependencies:
20492049
minimatch "^3.0.4"
20502050

2051-
immutable@^3.8.2:
2052-
version "3.8.2"
2053-
resolved "https://registry.yarnpkg.com/immutable/-/immutable-3.8.2.tgz#c2439951455bb39913daf281376f1530e104adf3"
2054-
20552051
import-cwd@^2.1.0:
20562052
version "2.1.0"
20572053
resolved "https://registry.yarnpkg.com/import-cwd/-/import-cwd-2.1.0.tgz#aa6cf36e722761285cb371ec6519f53e2435b0a9"

0 commit comments

Comments
 (0)