# react-svg-injector

> A React component that manipulate SVG and injects it using SVGInjector

Latest version **2.0.2** (published 2018-06-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-svg-injector
pnpm add react-svg-injector
yarn add react-svg-injector
bun add react-svg-injector
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2018-06-08 |
| First published | 2017-11-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 17.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Aaron A. Reisman |
| Maintainers | lifeiscontent |
| Keywords | react, svg |

## Links

- npm: https://www.npmjs.com/package/react-svg-injector
- Repository: https://github.com/lifeiscontent/react-svg-injector
- Homepage: https://github.com/lifeiscontent/react-svg-injector#readme
- Issues: https://github.com/lifeiscontent/react-svg-injector/issues
- npm.io page: https://npm.io/package/react-svg-injector

## Dependencies (1)

- [svg-injector](https://npm.io/package/svg-injector.md) 1.1.3

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

- 2.0.2 (latest) — 2018-06-08
- 2.0.1 — 2018-06-08
- 2.0.0 — 2018-05-15
- 1.1.9 — 2018-05-11
- 1.1.8 — 2018-05-11
- 1.1.7 — 2018-05-11
- 1.1.6 — 2018-05-11
- 1.1.5 — 2018-05-11
- 1.1.4 — 2018-05-11
- 1.1.3 — 2018-05-11
- 1.1.2 — 2018-05-11
- 1.1.1 — 2018-05-11
- 1.1.0 — 2018-05-11
- 1.0.4 — 2018-05-11
- 1.0.3 — 2018-05-11
- … 3 more at https://npm.io/package/react-svg-injector/versions

## README

# ReactSvgInjector

[![Greenkeeper badge](https://badges.greenkeeper.io/lifeiscontent/react-svg-injector.svg)](https://greenkeeper.io/)

## Example

```jsx
import React from "react";
import { ReactSvgInjector, Mutate } from "react-svg-injector";
import logo from "./logo.svg";

const Logo = props => (
  <ReactSvgInjector src={logo} className="App-logo">
    <Mutate selector="g" fill="#BADA55" />
  </ReactSvgInjector>
);

export default Logo;
```

## API

ReactSvgInjector exports 2 React Components `ReactSvgInjector` and `Mutate`.

### ReactSvgInjector

#### props

| name          | type     | description                                                                                                                   |
| ------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
| callback(svg) | function | callback which passes the svg element once it's been loaded                                                                   |
| evalScripts   | string   | option to tell ReactSvgInjector to eval scripts inside the svg element options are: `always`, `once`, `never` default: `once` |
| \*            | any      | all other props that are passed will be merged into the svg element                                                           |

### Mutate

#### props

| name     | type   | description                                                                               |
| -------- | ------ | ----------------------------------------------------------------------------------------- |
| selector | string | the selector of the node to modify                                                        |
| \*       | any    | all other props that are passed will be merged into the element that matches the selector |

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