Skip to content

Commit

Permalink
React 17 support: replace componentWillMount (#70)
Browse files Browse the repository at this point in the history
* Replace componentWillMount

* bump version

* test against latest react
  • Loading branch information
gpoitch authored Nov 17, 2020
1 parent 8d5c102 commit 626f973
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 79 deletions.
121 changes: 62 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-mobiledoc-editor",
"version": "0.11.0",
"version": "0.11.1",
"description": "A Mobiledoc editor for React apps",
"repository": "joshfrench/react-mobiledoc-editor",
"homepage": "https://github.com/joshfrench/react-mobiledoc-editor",
Expand Down Expand Up @@ -41,13 +41,13 @@
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/preset-react": "^7.12.5",
"@wojtekmaj/enzyme-adapter-react-17": "^0.3.1",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.1",
"chai": "^4.2.0",
"chai-enzyme": "1.0.0-beta.1",
"css-loader": "^5.0.1",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"eslint": "^7.13.0",
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-react": "^7.21.5",
Expand All @@ -60,8 +60,8 @@
"karma-webpack": "^4.0.2",
"mobiledoc-kit": "^0.13.2",
"mocha": "^8.2.1",
"react": "^16.8.0",
"react-dom": "^16.8.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"sinon": "^9.2.1",
"sinon-chai": "^3.5.0",
"style-loader": "^2.0.0",
Expand Down
32 changes: 17 additions & 15 deletions src/components/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,9 @@ class Container extends React.Component {
spellcheck: true
}

state = {
activeMarkupTags: [],
activeSectionTags: [],
activeSectionAttributes: []
}
constructor() {
super(...arguments);

getChildContext() {
return {
editor: this.editor,
activeMarkupTags: this.state.activeMarkupTags,
activeSectionTags: this.state.activeSectionTags,
activeSectionAttributes: this.state.activeSectionAttributes
};
}

componentWillMount() {
if (typeof this.props.willCreateEditor === 'function') {
this.props.willCreateEditor();
}
Expand All @@ -61,6 +48,21 @@ class Container extends React.Component {
}
}

state = {
activeMarkupTags: [],
activeSectionTags: [],
activeSectionAttributes: []
}

getChildContext() {
return {
editor: this.editor,
activeMarkupTags: this.state.activeMarkupTags,
activeSectionTags: this.state.activeSectionTags,
activeSectionAttributes: this.state.activeSectionAttributes
};
}

componentWillUnmount() {
this.editor.destroy();
}
Expand Down
2 changes: 1 addition & 1 deletion test/setup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chai from 'chai';
import chaiEnzyme from 'chai-enzyme';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
import sinonChai from 'sinon-chai';

Enzyme.configure({ adapter: new Adapter() });
Expand Down

0 comments on commit 626f973

Please sign in to comment.