当我将 Material-ui 中的 AppBar 标签写入由gatsby new
.
Warning: Unknown prop `onTouchTap` on <button> tag. Remove this prop from the element.
为了避免这种情况,我在根模板 (_template.jsx) 文件的顶部编写了这些代码。
import injectTapEventPlugin from 'react-tap-event-plugin';
try { // to prevent error because of loading twice
injectTapEventPlugin();
}
catch(e) {
console.warn( e );
}
这与 HMR 完美配合,但它很难看。
解决此问题的正确方法是什么?
更新:澄清 -gatsby new
克隆gatsby-starter-default,并且只有 React 组件。此外,在顶部导入和编写 injectTapEventPlugin/html.js
会引发错误Warning: Unknown prop onTouchTap on <button> tag
。这意味着没有正确调用 injectTapEventPlugin()。