-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gerardo Pacheco
committed
Nov 24, 2020
1 parent
0ac08dc
commit cc9044a
Showing
5 changed files
with
149 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { createContext, useCallback, useRef } from '@wordpress/element'; | ||
|
||
export const ClipboardContext = createContext( {} ); | ||
const { Provider, Consumer } = ClipboardContext; | ||
export { Consumer as ClipboardConsumer }; | ||
|
||
export default function ClipboardProvider( { children } ) { | ||
const clipboard = useRef(); | ||
const updateClipboard = useCallback( ( clipboardUpdate ) => { | ||
clipboard.current = clipboardUpdate; | ||
}, [] ); | ||
|
||
return ( | ||
<Provider value={ { clipboard, updateClipboard } }> | ||
{ children } | ||
</Provider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters