Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
wp-content
/
plugins
/
yith-woocommerce-wishlist
/
assets
/
js
/
src
/
utils
:
components-extension-context.js
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
import { createContext, useContextSelector } from 'use-context-selector'; const ComponentsExtensionContext = createContext( {} ); export const useComponentExtensionsContext = () => useContextSelector( ComponentsExtensionContext, state => state ); export const useComponentsExtension = ( hookName ) => { const extensions = useComponentExtensionsContext(); if ( ! extensions || ! (extensions[ hookName ] || null) ) { const EmptyFragment = () => <></>; EmptyFragment.isEmpty = true; return EmptyFragment; } return extensions[ hookName ]; } export const ComponentsExtensionProvider = ( { children, extensions } ) => ( <ComponentsExtensionContext.Provider value={ extensions }> { children } </ComponentsExtensionContext.Provider> );