Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @weknow/react-svgloader with all npm packages installed. Try it out:

var reactSvgloader = require("@weknow/react-svgloader")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@weknow/react-svgloader v1.0.9

ReactJS Component for Ajax SVG file loading and DOM Injection.

svgloader

This is a ReactJS Component for SVG file loading by Ajax and DOM injection. This component allow us to insert any SVG file specifying a path and adding a class name for css customization.

Example:

Please refer to the example file to see it working.

To run the example:

  1. Clone the repository
  2. Execute in console:
cd example
npm install
npm start

General Usage

As you will be able to see in example in order to use the component we need to importe it as:

import SvgLoader from 'bv-react-svgloader';

Then, in the render method we can just call it like:

<SvgLoader src='/svg/logo.svg' className="App-logo svg-logo"/>

Installation

Install this component is easy, just use npm as:

npm install bv-react-svgloader

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free