# fabricjs-react-mp

> support fabricjs from react

Latest version **1.0.4** (published 2021-10-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install fabricjs-react-mp
pnpm add fabricjs-react-mp
yarn add fabricjs-react-mp
bun add fabricjs-react-mp
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2021-10-17 |
| First published | 2021-10-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 18.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 149 |
| Author | Alejandro Soto - Ferry de Vries |
| Maintainers | ferris32 |

## Links

- npm: https://www.npmjs.com/package/fabricjs-react-mp
- Repository: https://github.com/asotog/fabricjs-react
- Homepage: https://github.com/asotog/fabricjs-react#readme
- Issues: https://github.com/asotog/fabricjs-react/issues
- npm.io page: https://npm.io/package/fabricjs-react-mp

## Recent versions

- 1.0.4 (latest) — 2021-10-17
- 1.0.3 — 2021-10-17
- 1.0.2 — 2021-10-17
- 1.0.1 — 2021-10-17

## README

# fabricjs-react

> support fabricjs from react

[![NPM](https://img.shields.io/npm/v/fabricjs-react.svg)](https://www.npmjs.com/package/fabricjs-react) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

We'll need to install `fabric`, `react` and `react-dom` because are peer dependencies of this library if you haven't yet otherwise install only what you don't have:
```bash
npm install --save fabricjs-react fabric react react-dom
```

## Usage

Take a look at sandbox: https://codesandbox.io/s/flamboyant-wind-ff3x8

```tsx
import React from 'react'

import { FabricJSCanvas, useFabricJSEditor } from 'fabricjs-react'

const App = () => {
  const { editor, onReady } = useFabricJSEditor()
  const onAddCircle = () => {
    editor?.addCircle()
  }
  const onAddRectangle = () => {
    editor?.addRectangle()
  }

  return (<div>
    <button onClick={onAddCircle}>Add circle</button>
    <button onClick={onAddRectangle}>Add Rectangle</button>
    <FabricJSCanvas className="sample-canvas" onReady={onReady} />
  </div>)
}

export default App
```

## Alternative use cases

### Add image ([#3](https://github.com/asotog/fabricjs-react/issues/3))
For this case, you have to reference the FabricJS dependency to first load the image:

```tsx
import { fabric } from 'fabric'; // this also installed on your project
import { useFabricJSEditor } from 'fabricjs-react';

const { selectedObjects, editor, onReady } = useFabricJSEditor();
fabric.Image.fromURL('my_image.png', function(oImg) { 
    editor.canvas.add( ... )
})
...
```
## License

MIT © [Alejandro Soto](https://github.com/Alejandro Soto)

Feel free to collaborate.

---
_Source: https://npm.io/package/fabricjs-react-mp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
