- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我将 "material-ui": "^1.0.0-beta.38"
更新为 "@material-ui/core": "^1.3.0"
。我更改了导入,运行 npm install,删除了 node_modules
甚至 package-lock.json
但我仍然收到模糊的错误消息 TypeError: Cannot read property 'muiName ' 的未定义
。
关于muiName的信息可以在here in the documentation上找到,但是好像和我的问题无关,是更新引起的。
该错误曾在 here 报告过一次,但由于缺少详细信息而关闭。
有人知道是什么原因造成的吗?
详细日志如下:
TypeError: Cannot read property 'muiName' of undefined
isMuiElement
D:/SC/projectPath/node_modules/@material-ui/core/utils/reactHelpers.js:31
28 | }
29 |
30 | function isMuiElement(element, muiNames) {
> 31 | return _react.default.isValidElement(element) && muiNames.indexOf(element.type.muiName) !== -1;
32 | }
33 |
34 | function isMuiComponent(element, muiNames) {
View compiled
(anonymous function)
D:/SC/projectPath/node_modules/@material-ui/core/FormControl/FormControl.js:135
132 |
133 | if (children) {
134 | _react.default.Children.forEach(children, function (child) {
> 135 | if (!(0, _reactHelpers.isMuiElement)(child, ['Input', 'Select', 'NativeSelect'])) {
136 | return;
137 | }
138 |
View compiled
forEachSingleChild
D:/SC/projectPath/node_modules/react/cjs/react.development.js:881
878 | var func = bookKeeping.func,
879 | context = bookKeeping.context;
880 |
> 881 | func.call(context, child, bookKeeping.count++);
882 | }
883 |
884 | /**
View compiled
traverseAllChildrenImpl
D:/SC/projectPath/node_modules/react/cjs/react.development.js:785
782 | }
783 |
784 | if (invokeCallback) {
> 785 | callback(traverseContext, children,
786 | // If it's the only child, treat the name as if it was wrapped in an array
787 | // so that it's consistent if the number of children grows.
788 | nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
View compiled
traverseAllChildren
D:/SC/projectPath/node_modules/react/cjs/react.development.js:856
853 | return 0;
854 | }
855 |
> 856 | return traverseAllChildrenImpl(children, '', callback, traverseContext);
857 | }
858 |
859 | /**
View compiled
forEachChildren [as forEach]
D:/SC/projectPath/node_modules/react/cjs/react.development.js:901
898 | return children;
899 | }
900 | var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
> 901 | traverseAllChildren(children, forEachSingleChild, traverseContext);
902 | releaseTraverseContext(traverseContext);
903 | }
904 |
View compiled
new FormControl
D:/SC/projectPath/node_modules/@material-ui/core/FormControl/FormControl.js:134
131 | var children = _this.props.children;
132 |
133 | if (children) {
> 134 | _react.default.Children.forEach(children, function (child) {
135 | if (!(0, _reactHelpers.isMuiElement)(child, ['Input', 'Select', 'NativeSelect'])) {
136 | return;
137 | }
View compiled
constructClassInstance
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:11447
11444 | }
11445 | }
11446 |
> 11447 | var instance = new ctor(props, context);
11448 | var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null;
11449 | adoptClassInstance(workInProgress, instance);
11450 |
View compiled
updateClassComponent
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:13144
13141 | if (current === null) {
13142 | if (workInProgress.stateNode === null) {
13143 | // In the initial pass we might need to construct the instance.
> 13144 | constructClassInstance(workInProgress, workInProgress.pendingProps, renderExpirationTime);
13145 | mountClassInstance(workInProgress, renderExpirationTime);
13146 |
13147 | shouldUpdate = true;
View compiled
beginWork
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:13824
13821 | case FunctionalComponent:
13822 | return updateFunctionalComponent(current, workInProgress);
13823 | case ClassComponent:
> 13824 | return updateClassComponent(current, workInProgress, renderExpirationTime);
13825 | case HostRoot:
13826 | return updateHostRoot(current, workInProgress, renderExpirationTime);
13827 | case HostComponent:
View compiled
performUnitOfWork
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:15863
15860 | startBaseRenderTimer();
15861 | }
15862 |
> 15863 | next = beginWork(current, workInProgress, nextRenderExpirationTime);
15864 |
15865 | if (workInProgress.mode & ProfileMode) {
15866 | // Update "base" time if the render wasn't bailed out on.
View compiled
workLoop
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:15902
15899 | if (!isAsync) {
15900 | // Flush all expired work.
15901 | while (nextUnitOfWork !== null) {
> 15902 | nextUnitOfWork = performUnitOfWork(nextUnitOfWork);
15903 | }
15904 | } else {
15905 | // Flush asynchronous work until the deadline runs out of time.
View compiled
HTMLUnknownElement.callCallback
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:100
97 | // nested call would trigger the fake event handlers of any call higher
98 | // in the stack.
99 | fakeNode.removeEventListener(evtType, callCallback, false);
> 100 | func.apply(context, funcArgs);
101 | didError = false;
102 | }
103 |
View compiled
invokeGuardedCallbackDev
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:138
135 | // Synchronously dispatch our fake event. If the user-provided function
136 | // errors, it will trigger our global error handler.
137 | evt.initEvent(evtType, false, false);
> 138 | fakeNode.dispatchEvent(evt);
139 |
140 | if (didError) {
141 | if (!didSetError) {
View compiled
invokeGuardedCallback
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:187
184 | * @param {...*} args Arguments for function
185 | */
186 | invokeGuardedCallback: function (name, func, context, a, b, c, d, e, f) {
> 187 | invokeGuardedCallback$1.apply(ReactErrorUtils, arguments);
188 | },
189 |
190 | /**
View compiled
replayUnitOfWork
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:15310
15307 | // Replay the begin phase.
15308 | isReplayingFailedUnitOfWork = true;
15309 | originalReplayError = thrownValue;
> 15310 | invokeGuardedCallback$2(null, workLoop, null, isAsync);
15311 | isReplayingFailedUnitOfWork = false;
15312 | originalReplayError = null;
15313 | if (hasCaughtError()) {
View compiled
renderRoot
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:15962
15959 |
15960 | var failedUnitOfWork = nextUnitOfWork;
15961 | if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
> 15962 | replayUnitOfWork(failedUnitOfWork, thrownValue, isAsync);
15963 | }
15964 |
15965 | // TODO: we already know this isn't true in some cases.
View compiled
performWorkOnRoot
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:16560
16557 | // This root is already complete. We can commit it.
16558 | completeRoot(root, finishedWork, expirationTime);
16559 | } else {
> 16560 | finishedWork = renderRoot(root, expirationTime, false);
16561 | if (finishedWork !== null) {
16562 | // We've completed the root. Commit it.
16563 | completeRoot(root, finishedWork, expirationTime);
View compiled
performWork
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:16482
16479 | }
16480 | } else {
16481 | while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && (minExpirationTime === NoWork || minExpirationTime >= nextFlushedExpirationTime)) {
> 16482 | performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false);
16483 | findHighestPriorityRoot();
16484 | }
16485 | }
View compiled
performSyncWork
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:16454
16451 | }
16452 |
16453 | function performSyncWork() {
> 16454 | performWork(Sync, false, null);
16455 | }
16456 |
16457 | function performWork(minExpirationTime, isAsync, dl) {
View compiled
requestWork
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:16354
16351 |
16352 | // TODO: Get rid of Sync and use current time?
16353 | if (expirationTime === Sync) {
> 16354 | performSyncWork();
16355 | } else {
16356 | scheduleCallbackWithExpiration(expirationTime);
16357 | }
View compiled
scheduleWork$1
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:16218
16215 | !isWorking || isCommitting$1 ||
16216 | // ...unless this is a different root than the one we're rendering.
16217 | nextRoot !== root) {
> 16218 | requestWork(root, nextExpirationTimeToWorkOn);
16219 | }
16220 | if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
16221 | invariant(false, 'Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.');
View compiled
scheduleRootUpdate
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:16785
16782 | }
16783 | enqueueUpdate(current, update, expirationTime);
16784 |
> 16785 | scheduleWork$1(current, expirationTime);
16786 | return expirationTime;
16787 | }
16788 |
View compiled
updateContainerAtExpirationTime
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:16812
16809 | container.pendingContext = context;
16810 | }
16811 |
> 16812 | return scheduleRootUpdate(current, element, expirationTime, callback);
16813 | }
16814 |
16815 | function findHostInstance(component) {
View compiled
updateContainer
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:16839
16836 | var current = container.current;
16837 | var currentTime = recalculateCurrentTime();
16838 | var expirationTime = computeExpirationForFiber(currentTime, current);
> 16839 | return updateContainerAtExpirationTime(element, container, parentComponent, expirationTime, callback);
16840 | }
16841 |
16842 | function getPublicRootInstance(container) {
View compiled
ReactRoot../node_modules/react-dom/cjs/react-dom.development.js.ReactRoot.render
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:17122
17119 | if (callback !== null) {
17120 | work.then(callback);
17121 | }
> 17122 | updateContainer(children, root, null, work._onCommit);
17123 | return work;
17124 | };
17125 | ReactRoot.prototype.unmount = function (callback) {
View compiled
(anonymous function)
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:17262
17259 | if (parentComponent != null) {
17260 | root.legacy_renderSubtreeIntoContainer(parentComponent, children, callback);
17261 | } else {
> 17262 | root.render(children, callback);
17263 | }
17264 | });
17265 | } else {
View compiled
unbatchedUpdates
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:16679
16676 | isUnbatchingUpdates = false;
16677 | }
16678 | }
> 16679 | return fn(a);
16680 | }
16681 |
16682 | // TODO: Batching should be implemented at the renderer level, not within
View compiled
legacyRenderSubtreeIntoContainer
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:17258
17255 | };
17256 | }
17257 | // Initial mount should not be batched.
> 17258 | unbatchedUpdates(function () {
17259 | if (parentComponent != null) {
17260 | root.legacy_renderSubtreeIntoContainer(parentComponent, children, callback);
17261 | } else {
View compiled
render
D:/SC/projectPath/node_modules/react-dom/cjs/react-dom.development.js:17317
17314 | return legacyRenderSubtreeIntoContainer(null, element, container, true, callback);
17315 | },
17316 | render: function (element, container, callback) {
> 17317 | return legacyRenderSubtreeIntoContainer(null, element, container, false, callback);
17318 | },
17319 | unstable_renderSubtreeIntoContainer: function (parentComponent, element, containerNode, callback) {
17320 | !(parentComponent != null && has(parentComponent)) ? invariant(false, 'parentComponent must be a valid React Component') : void 0;
View compiled
./src/index.js
D:/SC/projectPath/src/index.js:9
6 | import registerServiceWorker from './registerServiceWorker';
7 | import 'babel-polyfill';
8 |
> 9 | ReactDOM.render(
10 | <Provider store={store}>
11 | <App />
12 | </Provider>, document.querySelector('#root')
我的 package.json
文件如下所示
"dependencies": {
"babel-polyfill": "^6.26.0",
"classnames": "^2.2.5",
"css-loader": "^1.0.0",
"grunt": "^1.0.2",
"grunt-available-tasks": "^0.6.3",
"grunt-check-dependencies": "^1.0.0",
"grunt-npm-command": "^0.1.2",
"grunt-run": "^0.8.0",
"json-server": "^0.14.0",
"lodash": "^4.17.4",
"moment": "^2.20.1",
"prop-types": "^15.6.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-moment": "^0.7.9",
"react-mutation-observer": "^1.1.0",
"react-redux": "^5.0.6",
"react-router-dom": "^4.2.2",
"react-scripts": "1.1.4",
"redux": "^4.0.0",
"redux-devtools-extension": "^2.13.2",
"redux-thunk": "^2.2.0",
"typeface-roboto": "0.0.54",
"@material-ui/core": "^1.3.0"
}
最佳答案
我继承了一个最初在 Material-UI beta 上的项目,当我更新到 2.x.x 版本时,我开始遇到这个错误。
我的问题是如何导入组件。在 alpha 和 beta 版本(可能还有 1.x.x)中,一些组件是从另一个组件二次导出的。即。
从“@material-ui/core/List”导入列表,{ListItem};
在新版本中,每个组件都是从其自己的文件中默认导出的,这意味着您必须这样导入 ListItem
:从“@material-ui/core/ListItem”导入 ListItem;
为了简单起见(因为我必须更新许多导入)我使用了以下快捷方式:
从“@material-ui/core”导入{List, ListItem};
最重要的是,新版本的 Material-UI 试图解析不存在的元素,作为该文件的导出,并抛出一个错误,说它不理解你给它的是什么。这可能在某处的迁移文档中有所介绍,但如果能获得更可靠的错误消息就更好了。
关于javascript - 更新后的 Material UI 抛出 TypeError : Cannot read property 'muiName' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51493906/
我有一个 html 格式的表单: 我需要得到 JavaScript在value input 字段执行,但只能通过表单的 submit .原因是页面是一个模板所以我不控制它(不能有
我管理的论坛是托管软件,因此我无法访问源代码,我只能向页面添加 JavaScript 来实现我需要完成的任务。 我正在尝试用超链接替换所有页面上某些文本关键字的第一个实例。我还根据国家/地区代码对这些
我正在使用 JS 打开新页面并将 HTML 代码写入其中,但是当我尝试使用 document.write() 在新页面中编写 JS 时功能不起作用。显然,一旦看到 ,主 JS 就会关闭。用于即将打开的
提问不是为了解决问题,提问是为了更好地理解系统 专家!我知道每当你将 javascript 代码输入 javascript 引擎时,它会立即由 javascript 引擎执行。由于没有看过Engi
我在一个文件夹中有两个 javascript 文件。我想将一个变量的 javascript 文件传递到另一个。我应该使用什么程序? 最佳答案 window.postMessage用于跨文档消息。使
我有一个练习,我需要输入两个输入并检查它们是否都等于一个。 如果是 console.log 正则 console.log false 我试过这样的事情: function isPositive(fir
我正在做一个Web应用程序,计划允许其他网站(客户端)在其页面上嵌入以下javascript: 我的网络应用程序位于 http://example.org 。 我不能假设客户端网站的页面有 JQue
目前我正在使用三个外部 JS 文件。 我喜欢将所有三个 JS 文件合而为一。 尽一切可能。我创建 aio.js 并在 aio.js 中 src="https://code.jquery.com/
我有例如像这样的数组: var myArray = []; var item1 = { start: '08:00', end: '09:30' } var item2 = {
所以我正在制作一个 Chrome 扩展,它使用我制作的一些 TamperMonkey 脚本。我想要一个“主”javascript 文件,您可以在其中包含并执行其他脚本。我很擅长使用以下行将其他 jav
我有 A、B html 和 A、B javascript 文件。 并且,如何将 A JavaScript 中使用的全局变量直接移动到 B JavaScript 中? 示例 JavaScript) va
我需要将以下整个代码放入名为 activate.js 的 JavaScript 中。你能告诉我怎么做吗? var int = new int({ seconds: 30, mark
我已经为我的 .net Web 应用程序创建了母版页 EXAMPLE1.Master。他们的 I 将值存储在 JavaScript 变量中。我想在另一个 JS 文件中检索该变量。 示例1.大师:-
是否有任何库可以用来转换这样的代码: function () { var a = 1; } 像这样的代码: function () { var a = 1; } 在我的浏览器中。因为我在 Gi
我收到语法缺失 ) 错误 $(document).ready(function changeText() { var p = document.getElementById('bidp
我正在制作进度条。它有一个标签。我想调整某个脚本完成的标签。在找到可能的解决方案的一些答案后,我想出了以下脚本。第一个启动并按预期工作。然而,第二个却没有。它出什么问题了?代码如下: HTML:
这里有一个很简单的问题,我简单的头脑无法回答:为什么我在外部库中加载时,下面的匿名和onload函数没有运行?我错过了一些非常非常基本的东西。 Library.js 只有一行:console.log(
我知道 javascript 是一种客户端语言,但如果实际代码中嵌入的 javascript 代码以某种方式与在控制台上运行的代码不同,我会尝试找到答案。让我用一个例子来解释它: 我想创建一个像 Mi
我如何将这个内联 javascript 更改为 Unobtrusive JavaScript? 谢谢! 感谢您的回答,但它不起作用。我的代码是: PHP js文件 document.getElem
我正在寻找将简单的 JavaScript 对象“转储”到动态生成的 JavaScript 源代码中的最优雅的方法。 目的:假设我们有 node.js 服务器生成 HTML。我们在服务器端有一个对象x。
我是一名优秀的程序员,十分优秀!