问题
出于某些原因,我的React应用程序在发布到公司的DNS时以文档模式IE10作为标准运行。奇怪的管理员设置,我无法控制。
无论如何,都需要对IE10的支持。在IE 11中,使用建议的react-app-polyfills,它工作得很好
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';
然后,尝试使用ie9
而不是ie11
。没有成功,应用程序崩溃了。填充不起作用了吗?我收到了很多错误消息,例如:
Unhandled promise rejection Error: Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=object%20with%20keys%20%7B%7D&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
"Unhandled promise rejection"
{
[functions]: ,
description: "Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=object%20with%20keys%20%7B%7D&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.",
message: "Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=object%20with%20keys%20%7B%7D&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.",
name: "Error",
stack: "Error: Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=object%20with%20keys%20%7B%7D&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at _o (https://the-company's-domain.com/static/js/2.517170ee.chunk.js:2:559477)
at Anonymous function (https://the-company's-domain.com/static/js/2.517170ee.chunk.js:2:564365)
at Ra (https://the-company's-domain.com/static/js/2.517170ee.chunk.js:2:573836)
at gs (https://the-company's-domain.com/static/js/2.517170ee.chunk.js:2:614144)
at cu (https://the-company's-domain.com/static/js/2.517170ee.chunk.js:2:604884)
at su (https://the-company's-domain.com/static/js/2.517170ee.chunk.js:2:604812)
at Zs (https://the-company's-domain.com/static/js/2.517170ee.chunk.js:2:601824)
at Anonymous function (https://the-company's-domain.com/static/js/2.517170ee.chunk.js:2:553207)
at t.unsta",
Symbol()_a.ycgs6yczz5z: undefined,
Symbol()_m.ycgs6yczz5z: undefined,
Symbol(extensions)_16.ycgs6yczzi: undefined,
Symbol(foo)_1a.ycgs6yczzi: undefined,
Symbol(foo)_17.ycgs6yczzi: undefined,
Symbol(foo)_18.ycgs6yczzi: undefined,
Symbol(foo)_19.ycgs6yczzi: undefined,
Symbol(meta)_2.ycgs6yczz8v: { },
Symbol(nodejs.util.inspect.custom)_15.ycgs6yczzi: undefined,
Symbol(react.async_mode)_11.ycgs6yczzi: undefined,
Symbol(react.block)_10.ycgs6yczzi: undefined,
Symbol(react.concurrent_mode)_y.ycgs6yczziy: undefined,
Symbol(react.context)_t.ycgs6yczz5z: undefined,
Symbol(react.element)_n.ycgs6yczz5z: undefined,
Symbol(react.forward_ref)_u.ycgs6yczz5z: undefined,
Symbol(react.fragment)_p.ycgs6yczz5z: undefined,
Symbol(react.fundamental)_12.ycgs6yczzi: undefined,
Symbol(react.lazy)_x.ycgs6yczziy: undefined,
Symbol(react.memo)_w.ycgs6yczziy: undefined,
Symbol(react.portal)_o.ycgs6yczz5z: undefined,
Symbol(react.profiler)_r.ycgs6yczz5z: undefined,
Symbol(react.provider)_s.ycgs6yczz5z: undefined,
Symbol(react.responder)_13.ycgs6yczzi: undefined,
Symbol(react.scope)_14.ycgs6yczzi: undefined,
Symbol(react.strict_mode)_q.ycgs6yczz5z: undefined,
Symbol(react.suspense)_v.ycgs6yczz5z: undefined,
Symbol(react.suspense_list)_z.ycgs6yczziy: undefined
}
很难理解精简的包,因为我只能实时复制这个问题,而不是在开发中( create-react-app
中的一些依赖项不能与polyfill +热重新加载一起工作)。这个链接https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=object%20with%20keys%20%7B%7D&args[]=导致了这个结果:
Objects are not valid as a React child (found: object with keys {}). If you meant to render a collection of children, use an array instead.
这让我相信这与Object
上失败的polyfill有关……(我错了,请阅读下面的答案)
发布于 2021-01-12 01:34:05
解决方案
8小时后...(谢天谢地,我为此得到了报酬)
原来,在object 上的polyfill向对象添加了一个元素,当我迭代它时,它完全弄乱了我的代码,就像这样……
Object.entries(queryData.data.time).map((day) => {
... did stuff
奇怪的东西,在IE11或任何其他浏览器中都没有问题。
带走
显然,有些polyfills会向对象添加一个__proto__
元素。注意!
https://stackoverflow.com/questions/65671818
复制相似问题