简体   繁体   中英

react-fabricjs TypeError: Cannot read property 'bool' of undefined

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;

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.

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM