fix: correct module instead of react

This commit is contained in:
Hongarc 2019-04-25 10:02:00 +07:00
parent 64eb8ab773
commit 208a6c843a
5 changed files with 17 additions and 18 deletions

View file

@ -33,6 +33,7 @@
},
"dependencies": {
"backbone": "^1.4.0",
"fbjs": "^1.0.0",
"flux": "^3.1.3",
"jquery": "^3.4.0",
"markdown": "^0.5.0",

View file

@ -1,11 +1,12 @@
var Q = require('q');
var React = require('react');
var ReactDOM = require('react-dom');
var util = require('../util');
var Main = require('../app');
var intl = require('../intl');
var log = require('../log');
var React = require('react');
var Errors = require('../util/errors');
var Sandbox = require('../sandbox/').Sandbox;
var GlobalStateActions = require('../actions/GlobalStateActions');
@ -139,7 +140,7 @@ var Level = Sandbox.extend({
parent: this
}
);
React.render(
ReactDOM.render(
this.levelToolbar,
document.getElementById('levelToolbarMount')
);
@ -543,7 +544,7 @@ var Level = Sandbox.extend({
},
die: function() {
React.unmountComponentAtNode(
ReactDOM.unmountComponentAtNode(
document.getElementById('levelToolbarMount')
);

View file

@ -24,7 +24,7 @@ class CommandHistoryView extends React.Component {
this.props.commandCollection.on('change', this.scrollDown, this);
Main.getEvents().on('commandScrollDown', this.scrollDown, this);
Main.getEvents().on('clearOldCommands', this.clearOldCommands, this);
Main.getEvents().on('clearOldCommands', () => this.clearOldCommands(), this);
}
componentWillUnmount() {

View file

@ -1,8 +1,9 @@
var React = require('react');
var ReactDOM = require('react-dom');
var PropTypes = require('prop-types');
var reactUtil = require('../util/reactUtil');
var keyMirror = require('react/lib/keyMirror');
var keyMirror = require('fbjs/lib/keyMirror');
var STATUSES = keyMirror({
inqueue: null,
@ -24,16 +25,7 @@ class CommandView extends React.Component{
}
onModelDestroy() {
if (!this.isMounted()) {
return;
}
if (!this.getDOMNode) {
// WTF -- only happens in casperjs tests weirdly
console.error('this.getDOMNode not a function?');
return;
}
React.unmountComponentAtNode(this.getDOMNode().parentNode);
ReactDOM.unmountComponentAtNode(ReactDOM.findDOMNode(this).parentNode);
}
updateStateFromModel() {

View file

@ -14,12 +14,17 @@ class LevelToolbarView extends React.Component {
};
}
componentWillUnmount() {
this._isMounted = false;
}
componentDidMount() {
this._isMounted = true;
this.setState({
isHidden: this.props.parent.getIsGoalExpanded()
isHidden: this.props.parent.getIsGoalExpanded(),
isGoalExpanded: this.props.parent.getIsGoalExpanded()
});
this.props.parent.on('goalToggled', function() {
if (!this.isMounted()) {
if (!this._isMounted) {
return;
}