npm.io
0.2.0 • Published 6 years ago

react-g-canvas

Licence
MIT
Version
0.2.0
Deps
9
Size
82 kB
Vulns
0
Weekly
0
Stars
3

react-g

NPM version

NPM version

NPM version

Building visualization component in declarative and composable way.

Install

npm i @react-g/core
npm i @react-g/component
npm i @react-g/hooks

Example

import React, { useState, useEffect } from 'react';
import { Canvas, Group, Rect, Text } from '@react-g/core';

const App: React.FC = () => {
  const [color, setColor] = useState('yellow');

  useEffect(() => {
    const timer = setTimeout(() => {
      setColor('green');
    }, 3000);
    return () => clearTimeout(timer);
  }, []);

  return (
    <Canvas width={1000} height={800}>
      <Group>
        <Rect x={10} y={10} width={100} height={50} fill={color} stroke="#456734" />
        <Text x={200} y={60} text="test" fill="black" />
      </Group>
    </Canvas>
  );
};

export default App;

Doc

Keywords