,當我寫AppBar標籤從材料的UI成gatsby new
生成的代碼,我得到這個錯誤。如何使用材料的UI和injectTapEventPlugin與蓋茨比
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完美合作,但它很醜。
解決此問題的正確方法是什麼?
UPDATE:澄清 - gatsby new
克隆gatsby-starter-default,並且有唯一的反應的組分。 此外,進口和在/html.js
頂部寫injectTapEventPlugin引發錯誤Warning: Unknown prop onTouchTap on <button> tag
。這意味着injectTapEventPlugin()未被正確調用。
你正在import index.js中導入injectTapEventPlugin嗎?你可以嘗試在外面試試嗎? –
我在pages/_template.js中導入injectTapEventPlugin。如果我沒有嘗試這樣做,HMR中會出現以下錯誤。 '錯誤:injectTapEventPlugin():每一次應用程序lifecycle.' – pall