@sullivan/react-inject
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

npm version npm license

@sullivan/react-inject

Inject asset content dynamically in React 16.8.3+.

Installation

npm install --save @sullivan/react-inject

or

yarn add @sullivan/react-inject

Usage

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'

Package Sidebar

Install

npm i @sullivan/react-inject

Weekly Downloads

9

Version

0.1.0

License

MIT

Unpacked Size

5.48 kB

Total Files

7

Last publish

Collaborators

  • icarus-sullivan