Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use in React.js/webpack #3

Closed
wrightwriter opened this issue Jan 19, 2019 · 2 comments
Closed

How to use in React.js/webpack #3

wrightwriter opened this issue Jan 19, 2019 · 2 comments

Comments

@wrightwriter
Copy link

wrightwriter commented Jan 19, 2019

  1. Place
<script  src="https://cdn.jsdelivr.net/gh/tengbao/vanta/vendor/three.r92.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/tengbao/vanta/dist/vanta.fog.min.js"></script>

in index.html
Replace the ending of the filename with your desired effect.
2. Add a componentWillMount() listener and put in it

window.VANTA.FOG({
      el: "#dummy",
    });
@tengbao
Copy link
Owner

tengbao commented Mar 15, 2019

Thanks for the tip! I'll add this to the readme.

@M4lF3s
Copy link

M4lF3s commented Sep 16, 2019

As a quick note: You can also use this with Function-Components in React!

import vanta from './vanta.net.min.js';
import {useRef, useLayoutEffect} from 'react'

export default (props) => {
    const element = useRef<HTMLDivElement>()
    useLayoutEffect(() => {
        vanta({
            el: element.current
        })
    })
    return (
        <>
            <script src="/static/three.r92.min.js"></script>
            <div ref={element}></div>
        </>
    )
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants