Giter Club home page Giter Club logo

rive-examples-react's Introduction

Rive 2 React Component Example

Here's a simple example of how to create and use a React component for Rive 2. This uses Rive's Wasm runtime.

There are two sample components:

SimpleAnimation

SimpleAnimation continuously plays a looping animation. Provide it with the url to the file and the name of the animation to play:

<SimpleAnimation file='my_animation.riv' animation='MyAnimation' />

KnightAnimation

The KnightAnimation shows how to add custom behavior to an animation. When the animation is clicked on it toggles between two animations, mixing in, and transforming between, two animations in a file.

Running the Example

This project was bootstrapped with Create React App.

npm update

will pull down the necessary dependencies.

npm start

runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits and you will also see any lint errors in the console.

Notes on web bundling and deploying

  • Rive's web runtime uses Wasm to create a small, performant engine. Not all web bundlers play nicely with Wasm; if you run into difficulties, check your pipeline's documentation. In this example, we load the Wasm file from the unpkg cdn, but could just as easily load it from your hosting environment. Take a look at the RiveLoader.js source file.

  • If you get an error along the lines of Module not found: Can't resolve 'fs' and you're using webpack, try adding "node": { "fs": "empty" } to you config (webpack.config.js).

rive-examples-react's People

Contributors

alxgibsn avatar mjohnsullivan avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.