Gatsby: "react-particles-js" how to use SVG-image

Created on 8 Sep 2019  路  2Comments  路  Source: gatsbyjs/gatsby

I try to insert an SVG-image in my component create with "react-particles-js". But this is not working in Gatsby. Can anybody help?

import React from "react";
import Particles from "react-particles-js";
import "./myparticle.scss";

const MyParticle = () => (
  <Particles className={'dev'}
             params={{
               "particles": {
                 "shape":{
                   "type":["image"],
                   "image": {
                     "src": "./my-image.svg",
                     "width": 100,
                     "height": 100
                   }
                 }
               }
             }}
  />
);

export default MyParticle;

All 2 comments

This is because the library likely doesn't support server side rendering. Please open an issue in https://github.com/Wufe/react-particles-js

You can also use something like react-loadable to load libraries only in the client side (so that it works with Gatsby)

Find an example at https://github.com/fabe/gatsby-react-loadable

Closing this since it isn't a Gatsby issue but hope this helps you! 馃檪

I think you can try another library and he can also achieve your effect. very simple

https://github.com/lindelof/particles-bg

Was this page helpful?
0 / 5 - 0 ratings

Related issues

signalwerk picture signalwerk  路  3Comments

3CordGuy picture 3CordGuy  路  3Comments

kalinchernev picture kalinchernev  路  3Comments

rossPatton picture rossPatton  路  3Comments

benstr picture benstr  路  3Comments