0.1.0 • Published 4 years ago

@sullivan/react-inject v0.1.0

Weekly downloads
10
License
MIT
Repository
github
Last release
4 years ago

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'
0.1.0

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago