slate/components/core/PortalsProvider.js
Aminejv 3be39eccc4 feat(PortalsProvider): add PortalsProvider
- will be used with ReactDOM.createPortal to render components to elements that are outside their tree hierarchy
2021-09-27 10:13:04 +01:00

17 lines
491 B
JavaScript

import * as React from "react";
/**
* NOTE(amine): Component used to assign Portals in client side
*/
const LayoutContext = React.createContext({});
export default function PortalsProvider({ children }) {
const filterNavbar = React.useState();
const contextValue = React.useMemo(() => ({ filterNavbar }), [filterNavbar]);
return <LayoutContext.Provider value={contextValue}>{children}</LayoutContext.Provider>;
}
export const usePortals = () => React.useContext(LayoutContext);