|
|
@@ -21,21 +21,19 @@ class DoctorScreen extends React.Component {
|
|
|
};
|
|
|
}
|
|
|
static getDerivedStateFromProps(nextProps, prevState) {
|
|
|
- if (nextProps && 'patList' in nextProps && JSON.stringify(nextProps.patList) !== JSON.stringify(prevState.patList)) {
|
|
|
- return {
|
|
|
- patList: JSON.parse(JSON.stringify(nextProps?.patList || [])), // 防止重复渲染
|
|
|
- callPat: nextProps?.callPat || [],
|
|
|
- waitPat: initArray(nextProps?.waitPat || [], 7),
|
|
|
- };
|
|
|
+ let newState = {};
|
|
|
+ let nPatList = nextProps?.patList || [];
|
|
|
+ if (JSON.stringify(nPatList) !== JSON.stringify(prevState.patList)) {
|
|
|
+ newState.patList = JSON.parse(JSON.stringify(nPatList));
|
|
|
+ newState.callPat = nextProps?.callPat || [];
|
|
|
+ newState.waitPat = initArray(nextProps?.waitPat || [], 7);
|
|
|
}
|
|
|
- if (nextProps && 'reWaitPat' in nextProps && JSON.stringify(nextProps.reWaitPat) !== JSON.stringify(prevState.copyReWaitPat)) {
|
|
|
- let nReWaitPat = nextProps?.reWaitPat || [];
|
|
|
- return {
|
|
|
- copyReWaitPat: JSON.parse(JSON.stringify(nReWaitPat)), // 防止重复渲染
|
|
|
- reWaitPat: initArray(nReWaitPat, 8),
|
|
|
- };
|
|
|
+ let nReWaitPat = nextProps?.reWaitPat || [];
|
|
|
+ if (JSON.stringify(nReWaitPat) !== JSON.stringify(prevState.copyReWaitPat)) {
|
|
|
+ newState.copyReWaitPat = JSON.parse(JSON.stringify(nReWaitPat));
|
|
|
+ newState.reWaitPat = initArray(nReWaitPat, 8);
|
|
|
}
|
|
|
- return null;
|
|
|
+ return Object.keys(newState).length ? newState : null;
|
|
|
}
|
|
|
componentDidMount() {
|
|
|
// this.getQrcSrc('https://www.kimi.com/');
|