mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-30 12:26:00 +03:00
3be39eccc4
- will be used with ReactDOM.createPortal to render components to elements that are outside their tree hierarchy
17 lines
491 B
JavaScript
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);
|