import { useDispatch , useSelector } from 'react-redux' ; import { ReduxState , toggleSidebar } from 'ra-core' ; returns example export const useToggleSidebar = ( ) : UseToggleSidebarResult => { const open = useSelector < ReduxState , boolean > ( state => state . admin . ui . sidebarOpen ) ; const dispatch = useDispatch ( ) ; const toggle = ( ) => dispatch ( toggleSidebar ( ) ) ; return [ open , toggle ] ; } ; export type UseToggleSidebarResult = [ boolean , ( ) => void ] ;