1

I am trying to evaluate react-fabricjs package but it seems doesn't work with current React 16.12.0 version. The error I am getting is : TypeError: Cannot read property 'bool' of undefined in /./src/StaticCanvas.jsx?:414:40 followed by bunch of other errors. Any idea on how to use the Fabricjs or perhaps suggest another library?

To replicate the issue I simply create blank React app by npx create-react-app demo and add the package yarn add react-fabricjs --save

import logo from './logo.svg';
import './App.css';
import { Canvas, Text } from 'react-fabricjs';


function App() {
  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.js</code> and save to reload.
        </p>
              <Canvas
                  width="900"
                  height="900">
                  <Text
                      text="Hello World!"
                      left={300}
                      top={300}
                      fill="#000000"
                      fontFamily="Arial"
                  />
              </Canvas>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a>
      </header>
    </div>
  );
}

export default App;
Jim
  • 2,760
  • 8
  • 42
  • 66

1 Answers1

2

Taking a look at the error on a sandbox I've created using just this package, I can see that it's trying to access PropTypes from react's object.

Based on react docs:

React.PropTypes has moved into a different package since React v15.5

So, my assumption is that this module was built using a React version that still had PropTypes under its object.

enter image description here

You might consider looking for a different module as it seems that this one is no longer maintained.

Michalis Garganourakis
  • 2,872
  • 1
  • 11
  • 24
  • 1
    I do not really see any other react fabricjs packages, although the fabricjs itself looks very nice – Jim Jan 14 '20 at 19:39
  • 1
    I'm not familiar with fabric.js, but you can try to use [their module](https://www.npmjs.com/package/fabric) and create something from scratch based on your needs. I have created [a proof of concept](https://codesandbox.io/s/angry-tree-5hpyz) but I would strongly recommend you to take a look around the web as you might find a better approach from someone who is actually using it. – Michalis Garganourakis Jan 14 '20 at 20:08
  • 1
    [This](https://stackoverflow.com/a/58894059/10118832) seems like a nice approach to me. Also using fabric.js like I do on my example – Michalis Garganourakis Jan 14 '20 at 20:11
  • Hmm, it seems that the best way to use this library is not through the React but directly:) ... the goal is to create Visio like diagrams – Jim Jan 14 '20 at 20:39