# @sullivan/react-inject

> Load and inject static assets with React

Latest version **0.1.0** (published 2020-01-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sullivan/react-inject
pnpm add @sullivan/react-inject
yarn add @sullivan/react-inject
bun add @sullivan/react-inject
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2020-01-25 |
| First published | 2019-12-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Chris Sullivan |
| Maintainers | icarus-sullivan |
| Keywords | react, inject, svg, static, assets |

## Links

- npm: https://www.npmjs.com/package/@sullivan/react-inject
- Repository: https://github.com/icarus-sullivan/react-inject
- Homepage: https://github.com/icarus-sullivan/react-inject#readme
- Issues: https://github.com/icarus-sullivan/react-inject/issues
- npm.io page: https://npm.io/package/@sullivan/react-inject

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2020-01-25
- 0.0.2 — 2019-12-12
- 0.0.1 — 2019-12-10

## README

![npm version](https://img.shields.io/npm/v/@sullivan/react-inject.svg) ![npm license](https://img.shields.io/npm/l/@sullivan/react-inject.svg)

# @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

```javascript
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. 

```typescript
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'

---
_Source: https://npm.io/package/@sullivan/react-inject · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
