如何修复 Material-ui-dropzone 中的 theme.spacing.unit 警告?

meh*_*tar 3 reactjs material-ui

我像这样使用material-ui-dropzone:

//App.js
<Dropzone/>
Run Code Online (Sandbox Code Playgroud)

但控制台中出现了这个错误:

 index.js:1375 Warning: Material-UI: theme.spacing.unit usage has been deprecated. It will be removed in v5. You can replace `theme.spacing.unit * y` with `theme.spacing(y)`.
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个警告?

小智 5

首先:找到你的代码“theme.spacing.unit”;第二:例如:“theme.spacing.unit * 4”,请将其更改为“theme.spacing(4)”。


Eug*_*nic 5

以下是有关 v3 到 v4 过渡以及使用间距单位的完整文档。

链接:主题间距-v4

以下是有关间距单位的最常见示例:

基本间距单位

v3theme.spacing.unit

v4theme.spacing(1)

减少间距

v3theme.spacing.unit / 5

v4theme.spacing(1/5)

延长间距

v3theme.spacing.unit * 5

v4theme.spacing(5)