1.1.8 • Published 11 months ago

use-fabric v1.1.8

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

Use Canvas

React Hooks API for FabricJS canvas

Installation

npm i use-fabric
yarn add use-fabric

Usage

import { fabric } from 'fabric'
import { useFabric } from 'use-fabric'

function MyComponent() {

  const { canvas, Canvas } = useFabric({ backgroundColor: 'lightgray' }) // usual fabric.Canvas params

  function drawCircle() {
    if (canvas === 'error' || canvas === 'loading')
      return

    const circle = new fabric.Circle({...})
    canvas.add(circle)
  }

  return (
    <div>
      ...
      {Canvas}
    </div>
  )
}

Fabric dependency

Fabric depends on canvas, which is huge (>150 MB). We only depend on fabric as a peer dependency so that you're not forced to package it (and can use a CDN instead)

1.1.8

11 months ago

1.1.7

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.1

1 year ago

1.1.2

1 year ago

1.1.0

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago