我最近在嘗試使用React-Konva呈現Stage
時出現以下錯誤:Cannot read property 'getPooled' of null at Object.componentDidMount
。截至目前,我一直無法使用Konva渲染任何東西。我用typescript和webpack使用react-konva。 以下是我的簡化代碼:無法使用React-Konva呈現內容
.jsx:
import * as React from "react";
import * as ReactDOM from 'react-dom';
import { Layer, Stage, Rect, Group } from 'react-konva';
class Demo extends React.Component {
public render(): JSX.Element {
return (
<div style={{flex: 5}}>
<Stage width={320} height={320} style={{width: '100%', height: '100%'}}>
<Layer>
<Rect
height={32}
width={32}
x={0}
y={0}
fill={'#bb66bb'}
/>
</Layer>
</Stage>
</div>
);
}
}
我在反應,konva源代碼 var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
問題追查到此行哪我(我相信)追溯到ReactUpdates
(這是react-dom
的一部分)中的以下代碼。
var ReactUpdates = {
/**
* React references `ReactReconcileTransaction` using this property in order
* to allow dependency injection.
*
* @internal
*/
ReactReconcileTransaction: null,
...ommitted code here for brevity
};
module.exports = ReactUpdates;
顯然,所引用的屬性設置爲null
......我只是不明白爲什麼react-konva
正在引用此屬性,或者,如果我只是誤讀發生了什麼。有任何想法嗎? (另外,我正在使用v. 1.1.4 of react-konva
和v. 15.5.4 of react-dom
)
張貼解決方案的歡呼聲。 –