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": { "dependencies": {
"backbone": "^1.4.0", "backbone": "^1.4.0",
"fbjs": "^1.0.0",
"flux": "^3.1.3", "flux": "^3.1.3",
"jquery": "^3.4.0", "jquery": "^3.4.0",
"markdown": "^0.5.0", "markdown": "^0.5.0",

View file

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

View file

@ -13,7 +13,7 @@ var _subscribeEvents = [
class CommandHistoryView extends React.Component { class CommandHistoryView extends React.Component {
componentDidMount() { componentDidMount() {
for (var i = 0; i < _subscribeEvents.length; i++) { for (var i = 0; i < _subscribeEvents.length; i++) {
this.props.commandCollection.on( this.props.commandCollection.on(
_subscribeEvents[i], _subscribeEvents[i],
@ -24,7 +24,7 @@ class CommandHistoryView extends React.Component {
this.props.commandCollection.on('change', this.scrollDown, this); this.props.commandCollection.on('change', this.scrollDown, this);
Main.getEvents().on('commandScrollDown', 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() { componentWillUnmount() {

View file

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

View file

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