React/Materialui分页组件可以在本地工作,但不能在服务器上工作



有人能帮我解决这个问题吗?

  • [x]该问题出现在最新版本中
  • [x] 我已经搜索了这个存储库的问题,相信这不是重复的

当前行为😯

  • 我使用的是@material-ui/core:4.11.2和@material-ui/lab:4.0.0-alpha.57
  • 分页在本地工作,但在构建并部署到服务器后根本不起作用
  • 在服务器版本上,我在浏览器控制台中收到以下错误:

Uncaught TypeError: a is not a function at onClick (7f64add...e1.js:formatted:425)

参见屏幕截图

当我点击链接(7f64add…e1.js:格式化:425(时,我得到的是:

ActionsComponent: function(e) {
var t = e.count
, a = e.onChangePage;
return H("div", {
className: c.root
}, H(v.a, {
onClick: function(e) {
a(e, 0)
},
disabled: 0 === r,
"aria-label": "first page"
}, "rtl" === l.direction ? H(B.a, null) : H(T.a, null)), H(v.a, {
onClick: function(e) {
a(e, r - 1)
},
disabled: 0 === r,
"aria-label": "previous page"
}, "rtl" === l.direction ? H(A.a, null) : H(N.a, null)), H(v.a, {
onClick: function(e) {
a(e, r + 1)
},
disabled: r >= Math.ceil(t / o) - 1,
"aria-label": "next page"
}, "rtl" === l.direction ? H(N.a, null) : H(A.a, null)), H(v.a, {
onClick: function(e) {
a(e, Math.max(0, Math.ceil(t / o) - 1))
},
disabled: r >= Math.ceil(t / o) - 1,
"aria-label": "last page"
}, "rtl" === l.direction ? H(T.a, null) : H(B.a, null)))
},

突出显示此部分:

onClick: function(e) {
a(e, r + 1)
},

预期行为🤔

  • 它应该以与本地相同的方式工作

复制步骤🕹

  • 这是一个来自工作的封闭源代码项目,因此无法复制

环境🌎

  • 我正在使用react:16.14.0和next:9.5.5以及Chrome浏览器

问题已修复

我在这里找到了解决此问题的方法:https://github.com/mui-org/material-ui/issues/27192

它在页面顶部进行了解释,如下所示:

虽然道具弃用是一个非破坏性的变化是TablePaging中的一个特例,其中重命名onChangePage道具破坏了现有的代码。具体来说,将TablePagination与自定义ActionsComponent已损坏,因为提供给自定义ActionsComponent已从onChangePage更改->onPageChange。

相关内容

最新更新