【发布时间】:2018-08-21 16:43:04
【问题描述】:
我能够在sandbox 中重现错误。 这些是我看到的错误:
本地:
Warning: Stateless function components cannot be given refs. Attempts to access this ref will fail.
Check the render method of `WithStyles(Card)`.
in Card (created by WithStyles(Card))
in WithStyles(Card) (at Todo.js:112)
本地和Sandbox:
Invariant failed: Cannot get draggable ref from drag handle
从我的谷歌搜索来看,我似乎不能使用withStyles,因为它是一个无状态的功能组件。如果是这种情况,有什么替代方案?我想继续使用 withStyle 包装器的好处(它将 mui 主题和样式表注入到组件中)。
请注意,为了清楚起见,我简化了沙箱代码(例如,我删除了 redux)。
【问题讨论】:
标签: reactjs material-ui