import { useEffect } from 'react';
import { useCollectionPageContext } from '../providers';
import { reaction, runInAction } from 'mobx';
export const useSyncTotal = (state) => {
    const pageState = useCollectionPageContext();
    useEffect(() => {
        if (state.totalStatus === 'success') {
            runInAction(() => {
                pageState.total = state.total;
            });
        }
        return reaction(() => ({
            status: state.totalStatus,
            total: state.total,
        }), ({ status, total }) => {
            pageState.total = status === 'success' ? total : false;
        });
    }, []);
};
//# sourceMappingURL=useSyncTotal.js.map