@sullivan/react-inject
v0.1.0
Published
Load and inject static assets with React
Maintainers
Readme
@sullivan/react-inject
Inject asset content dynamically in React 16.8.3+.
Installation
npm install --save @sullivan/react-injector
yarn add @sullivan/react-injectUsage
import React from 'react';
import ReactInject from '@sullivan/react-inject';
const Circle = (props) => (
<ReactInject src="/asset/circle.svg" />
);
export default Circle;Props
If an id is used, ReactInject will try to inject into the result of getElementById. If not, a new element will be created and the content will be injected there. To control the newly created element pass a tag prop.
type ReactInjectProps {
id?: string,
tag?: string,
src: string,
}Changelog
0.1.0
- Add the ability to create a specific type of element instead of defaulting to a 'div'
