feat: reduce render times

This commit is contained in:
infeng 2019-09-17 14:41:39 +08:00
parent 5a398477ee
commit e5c30aafa0

View File

@ -114,6 +114,7 @@ export default (props: ViewerProps) => {
return {
...s,
activeIndex: action.payload.index,
startLoading: true,
};
case ACTION_TYPES.update:
return {
@ -160,13 +161,11 @@ export default (props: ViewerProps) => {
React.useEffect(() => {
if (visible) {
setTimeout(() => {
if (init.current) {
dispatch(createAction(ACTION_TYPES.setVisible, {
visible: true,
}));
}
}, 10);
if (init.current) {
dispatch(createAction(ACTION_TYPES.setVisible, {
visible: true,
}));
}
}
}, [visible]);
@ -296,15 +295,6 @@ export default (props: ViewerProps) => {
}
}, [state.startLoading, state.activeIndex]);
React.useEffect(() => {
if (state.activeIndex === null || !state.visible) {
return;
}
dispatch(createAction(ACTION_TYPES.update, {
startLoading: true,
}));
}, [state.activeIndex, state.visible]);
function getImgWidthHeight(imgWidth, imgHeight) {
let width = 0;
let height = 0;