Skip to content

Commit

Permalink
Merge pull request #73 from HubSpot/unsafe-prefix
Browse files Browse the repository at this point in the history
Use unsafe prefix method names'
  • Loading branch information
Friss authored Oct 30, 2019
2 parents 1638000 + 0dfb955 commit 96425f6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.1.0
* Use `UNSAFE_` prefix for `componentWillMount`, `componentWillReceiveProps` usages in `connect` HOC.

## 3.0.1
* Externalize `hoist-non-react-statics` from CJS and ESM bundles.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "general-store",
"version": "3.0.1",
"version": "3.1.0",
"description": "Simple, flexible store implementation for Flux.",
"main": "lib/GeneralStore.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/dependencies/__tests__/connect-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('connect', () => {
});
});

describe('componentWillMount', () => {
describe('UNSAFE_componentWillMount', () => {
it('registers a callback with the dispatcher', () => {
shallow(<MockComponent />);
expect(dispatcher.register.mock.calls.length).toEqual(3);
Expand All @@ -128,7 +128,7 @@ describe('connect', () => {
});
});

describe('componentWillReceiveProps', () => {
describe('UNSAFE_componentWillReceiveProps', () => {
it('calculates and sets state', () => {
const root = shallow(<MockComponent />);
root.setProps({ add: 2 });
Expand Down
4 changes: 2 additions & 2 deletions src/dependencies/connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function connect(
state: any = {};
wrappedInstance?: HTMLElement = null;

componentWillMount() {
UNSAFE_componentWillMount() {
if (dispatcher) {
this.dispatchToken = dispatcher.register(
handleDispatch.bind(
Expand All @@ -55,7 +55,7 @@ export default function connect(
this.setState(calculateInitial(dependencies, this.props, this.state));
}

componentWillReceiveProps(nextProps: Object) {
UNSAFE_componentWillReceiveProps(nextProps: Object) {
this.setState(
calculateForPropsChange(dependencies, nextProps, this.state)
);
Expand Down

0 comments on commit 96425f6

Please sign in to comment.