Package Exports
- use-interpolate
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (use-interpolate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
use-interpolate 📃
A react hook that interpolates html(text) into a component.
Install
npm i use-interpolateExample
Basic
import useInterpolate from 'use-interpolate'
function App(){
const reactElement = useInterpolate(
`<0>phone</0> :<1/> <2/> - <3/>`,
{
0: (children) => <span>*{children}</span>,
1: <br/>,
2: <Input theme='red'/>,
3: <Input theme='blue'/>
}
)
return reactElement
}output:
<>
<span>*phone</span> :<br/> <Input theme='red'/> - <Input theme='blue'/>
</>Change tag brackets.
import {createHook} from 'use-interpolate'
const useInterpolate = createHook({ tag: ['{', '}'] })
function App(){
return useInterpolate('hello {0}world{/0}', {0: <span/>})
}output:
<>
hello <span>world</span>
</>License
MIT