XYZ File Manager
Current Path:
/var/www/wordpress/wp-content/plugins/code-snippets/js/utils
var
/
www
/
wordpress
/
wp-content
/
plugins
/
code-snippets
/
js
/
utils
/
📁
..
📄
Linter.ts
(4.44 KB)
📄
errors.ts
(80 B)
📄
files.ts
(1.44 KB)
📄
hooks.ts
(498 B)
📄
restAPI.ts
(473 B)
📄
screen.ts
(249 B)
📁
snippets
📄
text.ts
(787 B)
Editing: hooks.ts
import { createContext, useContext } from 'react' import type { Context } from 'react' export const createContextHook = <T>(name: string): [ Context<T | undefined>, () => T ] => { const contextValue = createContext<T | undefined>(undefined) const useContextHook = (): T => { const value = useContext(contextValue) if (value === undefined) { throw Error(`use${name} can only be used within a ${name} context provider.`) } return value } return [contextValue, useContextHook] }
Upload File
Create Folder