React 17 正式版已经发布,本次版本变更日志如下:
react/jsx-runtime
和 react/jsx-dev-runtime
。displayName
以改善调用栈信息。'use strict'
从 UMD 的 bundles 中泄露。fb.me
进行重定向。document
切换为 root。useEffect
清理函数。focusin
和 focusout
替换 onFocus
和 onBlur
的底层实现。Capture
事件都使用浏览器的捕获阶段实现。onScroll
事件时冒泡。forwardRef
或 memo
组件的返回值为 undefined
,则抛出异常。console
。ReactTestUtils.SimulateNative
API。ReactDOM.flushSync
(但会发出警告)。code
属性添加到键盘事件对象中。video
元素添加 disableRemotePlayback
属性。input
元素添加 enterKeyHint
属性。<Context.Provider>
提供任何值时,会发出警告。forwardRef
或 memo
组件的返回值为 undefined
,则抛出警告。onTouchStart
、onTouchMove
和 onWheel
默认为 passive。setState
挂起的问题。defaultProps
修复拉架子组件在渲染时的问题。dangerouslySetInnerHTML
为 undefined
时,误报警告的问题。require
实现来修复 Test Utils。onBeforeInput
报告错误的 event.type
。event.relatedTarget
输出为 undefined
的问题。movementX/Y
polyfill 的问题。onSubmit
和 onReset
事件。useCallback
与 useMemo
一致。findByType
错误信息。unstable_
前缀。 unstable_discreteUpdates
和 unstable_flushDiscreteUpdates
。timeoutMs
参数。<div hidden />
预渲染,以支持未来的 API。unstable_expectedLoadTime
,用于 CPU-bound 树。unstable_useOpaqueIdentifier
Hook。unstable_startTransition
API. act
后,不在刷新 Suspense 的 fallback。useMutableSource
中的 bug,此 bug 可能在 getSnapshot
更改时出现。useMutableSource
令人恶心的 bug。setState
,会发出警告。
react v17 新特性详情:https://reactjs.org/blog/2020/10/20/react-v17.html
(文/开源中国)