0.3.3 • Published 6 years ago

@theatre/hooks v0.3.3

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

TheatreJS Hooks

Using TheatreJS with React, easy as pie 🥧

Installation

yarn add @theatre/hooks

Usage

import React from 'react';
import { useTheatre } from '@theatre/hooks';

const project = Theatre.getProject('My Awesome Project');
const timeline = project.getTimeline('My Awesome Timeline');

const Component = () => {
  const { x, y } = useTheatre('Box', ['x', 'y'], timeline);
  
  return (
    <div>{x} {y}</div>
  );
}

Or as a suggestion you can put your timelines in an external file so you'll be able to use this hook like:

import React from 'react';
import { useTheatre } from '@theatre/hooks';

import { TLJumping, TLBouncing } from './Timelines'

const Component = () => {
  const { x, y } = useTheatre('Box', ['x', 'y'], TLJumping);
  const { squish } = useTheatre('Box', ['squish'], TLBouncing);
  
  return (
    <div>{x} {y} {squish}</div>
  );
}
0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago