После обновления приложений React для использования типов свойств я получаю сообщение об ошибке ниже.
ошибка
Uncaught ReferenceError: require is not defined
api_error_app. js .jsx
"use strict";
import PropTypes from "prop-types";
class ApiErrorApp extends React.Component {
constructor(props) {
super(props);
/*
* State holds reasons and errors for the selected reason
*/
this.state = {
reasons: [],
errors: []
};
}
/*
* if the store changes, we watch for events to be emmitted
* then set the state for the application
*/
_onChange() {
const { reason }= this.context.router.getCurrentParams();
this.setState({
reasons: ApiErrorStore.allReasons(), errors: ApiErrorStore.errorsForReason(reason) }, function(){
if (this.state.errors.length == 0) {
if (this.state.reasons.length == 0) {
router.transitionTo('api-error-root')
} else {
router.transitionTo('error-reason', {reason: reason || this.state.reasons[0].reason});
}
} else {
// transition to first error
router.transitionTo('error', {reason: reason, id: this.state.errors[0].id});
}
});
}
/*
* when mounted, watch for store changes
*/
componentDidMount() {
ApiErrorStore.addChangeListener(this._onChange.bind(this));
}
/*
* stop watching for store changes when unmounted
*/
componentWillUnmount() {
ApiErrorStore.removeChangeListener(this._onChange.bind(this));
}
/*
* generic render function
*
* @returns @jsx
*/
render() {
return (
<div className="api-error-app">
<ErrorList reasons={this.state.reasons}/>
<ReactRouter.RouteHandler errors={this.state.errors} />
</div>
);
}
}
ApiErrorApp.contextTypes = {
router: PropTypes.func,
};