ReactJS + SVG Files Component
Hi there!
Today I will present this awesome React component that will allow us to include any SVG file via Ajax and inject it to the DOM.
This component offer us 3 important advantage:
-. First, we don't need any other module to use it.
-. Second, the files will be loaded by Ajax and inserted in the DOM.
-. And thirst, we can customize them with CSS.
In order to install the component we just execute
npm install bv-react-svgloader
inside of our React project.
Then we need to include the module where we need it
import SvgLoader from 'bv-react-svgloader';
and of course insert it in our render function like
<SvgLoader src='/svg/logo.svg' className="svg-logo"/>
Please refer to the repo to check an example or just give a close look to the code:
Thanks!