react-svg-injector

2.0.2 • Public • Published

ReactSvgInjector

Greenkeeper badge

Example

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

Readme

Keywords

Package Sidebar

Install

npm i react-svg-injector

Weekly Downloads

3

Version

2.0.2

License

MIT

Unpacked Size

17.5 kB

Total Files

5

Last publish

Collaborators

  • lifeiscontent