
Product
A New Overview in our Dashboard
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
fabricjs-react
Advanced tools
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:
npm install --save fabricjs-react fabric react react-dom
Take a look at sandbox: https://codesandbox.io/s/flamboyant-wind-ff3x8
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
For this case, you have to reference the FabricJS dependency to first load the image:
import { fabric } from 'fabric'; // this also installed on your project
import { useFabricJSEditor } from 'fabricjs-react';
const { selectedObjects, editor, onReady } = useFabricJSEditor();
useEffect(() => {
fabric.Image.fromURL('my_image.png', function (oImg) {
editor?.canvas.add(oImg);
});
}, [fabric, editor])
...
MIT © [Alejandro Soto](https://github.com/Alejandro Soto)
Feel free to collaborate.
FAQs
support fabricjs from react
The npm package fabricjs-react receives a total of 3,188 weekly downloads. As such, fabricjs-react popularity was classified as popular.
We found that fabricjs-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.