1.0.1 • Published 5 years ago
wrappedcopy v1.0.1
Wrappedcopy - (NOT PRODUCTION TESTED)
Wrap an Element - Click and It's Copied -
Gives you access to context similar to useFormikContext
Install
yarn add wrappedcopyUsage
Important
You must Wrap you app with the Context Provider, Provided.
Ps. You can also just Wrap your View
import React, { Component } from 'react'
import { WrappedCopyContextProvider } from 'wrappedcopy'
class Example extends Component {
render() {
return (
<WrappedCopyContextProvider>
<App />
</WrappedCopyContextProvider>
)
}
}Then in your View -
import React, { Component } from 'react'
import { WrappedElement, useCopiedContext } from 'wrappedcopy'
const MyComponent = () => {
const { copiedText } = useCopiedContext()
return (
<div>
<WrappedElement>Hello</WrappedElement>
</div>
)
}Wrap the element you want to be Copied to your clipboard with <WrappedElement>
Should You need to read the value copied you can destruct it from the Copied Context using
const {copiedText} = useCopiedContext()
Issues
I have not tested on Classes but will soon as I need Legacy support for this
As such for failsafe I export the raw Context as-well
import {CopyContext} from 'wrappedcopy'
Development
yarn start # runs rollup with watch flagcd example
yarn
yar start # runs create-react-app dev serverMade with create-react-library
Publishing to NPM
yarn publishDeploying to Github Pages
yarn run deployLicense
MIT © ahwelgemoed