forked from p96170835/amis
修复报错'
This commit is contained in:
parent
46ba154e5a
commit
4308570905
|
@ -224,6 +224,7 @@ export class ToastMessage extends React.Component<ToastMessageProps> {
|
|||
|
||||
// content: React.RefObject<HTMLDivElement>;
|
||||
timer: NodeJS.Timeout;
|
||||
mounted: boolean = false;
|
||||
constructor(props: ToastMessageProps) {
|
||||
super(props);
|
||||
|
||||
|
@ -234,16 +235,18 @@ export class ToastMessage extends React.Component<ToastMessageProps> {
|
|||
this.close = this.close.bind(this);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearTimeout(this.timer);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.mounted = true;
|
||||
this.setState({
|
||||
visible: true
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearTimeout(this.timer);
|
||||
this.mounted = false;
|
||||
}
|
||||
|
||||
handleMouseEnter() {
|
||||
clearTimeout(this.timer);
|
||||
}
|
||||
|
@ -254,7 +257,9 @@ export class ToastMessage extends React.Component<ToastMessageProps> {
|
|||
|
||||
handleEntered() {
|
||||
const timeOut = this.props.timeOut;
|
||||
this.timer = setTimeout(this.close, timeOut);
|
||||
if (this.mounted) {
|
||||
this.timer = setTimeout(this.close, timeOut);
|
||||
}
|
||||
}
|
||||
|
||||
close() {
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
import {types, getParent, SnapshotIn, flow, getRoot} from 'mobx-state-tree';
|
||||
import {
|
||||
types,
|
||||
getParent,
|
||||
SnapshotIn,
|
||||
flow,
|
||||
getRoot,
|
||||
hasParent
|
||||
} from 'mobx-state-tree';
|
||||
import {IFormStore} from './form';
|
||||
import {str2rules, validate as doValidate} from '../utils/validations';
|
||||
import {Api, Payload, fetchOptions} from '../types';
|
||||
|
@ -59,11 +66,11 @@ export const FormItemStore = types
|
|||
})
|
||||
.views(self => {
|
||||
function getForm(): any {
|
||||
return getParent(self, 2);
|
||||
return hasParent(self, 2) ? getParent(self, 2) : null;
|
||||
}
|
||||
|
||||
function getValue(): any {
|
||||
return getForm().getValueByName(self.name);
|
||||
return getForm() ? getForm().getValueByName(self.name) : undefined;
|
||||
}
|
||||
|
||||
function getLastOptionValue(): any {
|
||||
|
|
Loading…
Reference in New Issue