UNPKG

@zendeskgarden/react-theming

Version:

Theming utilities and components within the Garden Design System

22 lines (19 loc) 539 B
/** * Copyright Zendesk, Inc. * * Use of this source code is governed under the Apache License, Version 2.0 * found at http://www.apache.org/licenses/LICENSE-2.0. */ import { useState, useEffect } from 'react'; const useDocument = theme => { const [controlledDocument, setControlledDocument] = useState(); useEffect(() => { if (theme && theme.document) { setControlledDocument(theme.document); } else { setControlledDocument(document); } }, [theme]); return controlledDocument; }; export { useDocument };