import React, { useRef, useEffect } from 'react';

export const useAuth = (navigation) => {
    const auth = navigation.getParam('auth', { Access:false, Update:false, Delete:false, Business:false });
    const userinfo = navigation.getParam('userinfo', {BusinessFieldId:0, Name:'', SiteId:0, SiteName:'', UserGroupId:0, UserId:''});
    const sitemap = navigation.getParam('sitemap', {name:'', auth:{}, path:'', icon:'', id:0, parentid:0});
    const config = navigation.getParam('config', {});
    return { auth, userinfo, sitemap, config };
}

export const usePrevious = (value) => {
    const ref = useRef();
    useEffect(() => {
        ref.current = value;
    }, [value]);
    return ref.current;
}
