Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React 18 #77046

Merged
merged 35 commits into from
Jun 27, 2023
Merged

React 18 #77046

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
32c71ad
Update packages to be compatible with React 18
noahtallen May 17, 2023
d8c30f1
Update internal peer dependencies
noahtallen May 19, 2023
465561e
Resolve peer dependency issues
noahtallen Jun 1, 2023
9963a26
Update several internal tsconfig references
tyxla Jun 1, 2023
79ec7c7
Add stream fallback in webpack
noahtallen Jun 3, 2023
cc724f5
Attempt removing jsx import alias
noahtallen Jun 3, 2023
cb4c60c
Update snapshots to remove whitespace
noahtallen Jun 3, 2023
4aa05a9
Remove custom @types/react patch and pin react 18 types
noahtallen Jun 20, 2023
976fd95
Fix issues with children type in React props
noahtallen Jun 21, 2023
611d802
Fix type issues related to useCallback function arguments
noahtallen Jun 21, 2023
829d068
Fix issues with the store selector types
noahtallen Jun 21, 2023
ec9f797
Remove some uneeded React types
noahtallen Jun 21, 2023
92d1ad8
remove an unused ts-expect-error call
noahtallen Jun 21, 2023
44d5677
Add ReactNode types to an inline function component
noahtallen Jun 21, 2023
a3b424f
Change a use of a component to call it directly
noahtallen Jun 21, 2023
e1b0e6f
Fix a type related to interpolate element (ReactNode->ReactElement)
noahtallen Jun 22, 2023
f4bf0a1
Cast known render values to string
noahtallen Jun 22, 2023
2ed48da
Fix context types in legacy class component
noahtallen Jun 22, 2023
1d82607
Fix incorrect prop type (Node->ReactNode)
noahtallen Jun 22, 2023
0bcaba2
Fix a type issue with an action creator
noahtallen Jun 23, 2023
b526bce
Remove fallback translation which was causing a type error
noahtallen Jun 23, 2023
fd8dbfc
Fix an odd issue where children were passed as a function
noahtallen Jun 23, 2023
9316149
Improve generics for use track callback useCallback
noahtallen Jun 23, 2023
3b61b43
Cast render type to ReactNode and add comment
noahtallen Jun 23, 2023
c4a0c7b
Cast const array to readonlyarray so we can use .includes on it
noahtallen Jun 23, 2023
7a7187a
Another yarn.lock update
noahtallen Jun 23, 2023
fa93be5
Enable allowDeclareFields for typescript classes in babel preset
noahtallen Jun 23, 2023
9050665
Fix babel config preset syntax
tyxla Jun 23, 2023
b43edac
Try with casting for now
tyxla Jun 23, 2023
c98055d
Fix a bunch of package unit tests
tyxla Jun 23, 2023
54e6989
Fix a bunch of client unit tests
tyxla Jun 23, 2023
1d91653
Conditionally run layout effects in SSR
noahtallen Jun 23, 2023
fa1888a
Import react dom server from browser bundle explicitly
noahtallen Jun 23, 2023
148325e
Attempt defining TextEncoder globally for tests
noahtallen Jun 23, 2023
911478e
Attempt downgrading use-subscription to fix SSR bug
noahtallen Jun 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .yarn/patches/@types-react-npm-17.0.39-b4ac1f7bfe.patch

This file was deleted.

172 changes: 52 additions & 120 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,121 +1,58 @@
### Basic Yarn settings. ###
compressionLevel: 0

nodeLinker: node-modules
enableGlobalCache: true
preferAggregateCacheInfo: true
yarnPath: .yarn/releases/yarn-3.2.3.cjs

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

### Log filters to discard irrelevant warnings. ###
logFilters:
# The fsevents warning is useless, so discard it:
- level: discard
pattern: "fsevents@*/* The * architecture is incompatible with this module, link skipped."

# Newspack blocks has many transitive dependencies without React 18 explicitly supported, so we need to ignore those.
- level: discard
pattern: "@automattic/wpcom-editing-toolkit@workspace:apps/editing-toolkit provides react (pc86c0) with version 17.0.2, which doesn't satisfy what @automattic/newspack-blocks and some of its descendants request"
- level: discard
pattern: "@automattic/wpcom-editing-toolkit@workspace:apps/editing-toolkit provides react-dom (p9837d) with version 17.0.2, which doesn't satisfy what @automattic/newspack-blocks and some of its descendants request"
- level: discard
pattern: "calypso@workspace:client provides react (p44ec6) with version 17.0.2, which doesn't satisfy what react-live and some of its descendants request"
- level: discard
pattern: "calypso@workspace:client provides react-dom (p2ead7) with version 17.0.2, which doesn't satisfy what react-live and some of its descendants request"
- level: discard
pattern: "wp-calypso@workspace:. provides react (*) with version 17.0.2, which doesn't satisfy what @types/wordpress__block-editor and some of its descendants request"
- level: discard
pattern: "wp-calypso@workspace:. provides react-dom (*) with version 17.0.2, which doesn't satisfy what @types/wordpress__block-editor and some of its descendants request"
- level: discard
pattern: "calypso@workspace:client provides react (*) with version 17.0.2, which doesn't satisfy what @automattic/design-preview and some of its descendants request"
- level: discard
pattern: "calypso@workspace:client provides react-dom (*) with version 17.0.2, which doesn't satisfy what @automattic/design-preview and some of its descendants request"
- level: discard
pattern: "calypso@workspace:client provides react (*) with version 17.0.2, which doesn't satisfy what @wordpress/block-editor and some of its descendants request"
- level: discard
pattern: "calypso@workspace:client provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/block-editor and some of its descendants request"
- level: discard
pattern: "@automattic/o2-blocks@workspace:apps/o2-blocks provides react (*) with version 17.0.2, which doesn't satisfy what @wordpress/block-editor and some of its descendants request"
- level: discard
pattern: "@automattic/o2-blocks@workspace:apps/o2-blocks provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/block-editor and some of its descendants request"
- level: discard
pattern: "@automattic/wpcom-block-editor@workspace:apps/wpcom-block-editor provides react (*) with version 17.0.2, which doesn't satisfy what @wordpress/block-editor and some of its descendants request"
- level: discard
pattern: "@automattic/wpcom-block-editor@workspace:apps/wpcom-block-editor provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/block-editor and some of its descendants request"
- level: discard
pattern: "@automattic/wpcom-editing-toolkit@workspace:apps/editing-toolkit provides react (*) with version 17.0.2, which doesn't satisfy what @wordpress/block-editor and some of its descendants request"
- level: discard
pattern: "@automattic/wpcom-editing-toolkit@workspace:apps/editing-toolkit provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/block-editor and some of its descendants request"
- level: discard
pattern: "wp-calypso@workspace:. provides react (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "calypso@workspace:client provides react (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "@automattic/o2-blocks@workspace:apps/o2-blocks provides react (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "@automattic/search@workspace:packages/search *provides react (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "happy-blocks@workspace:apps/happy-blocks provides react (*) with version 17.0.2, which doesn't satisfy what @wordpress/block-editor and some of its descendants request"
- level: discard
pattern: "happy-blocks@workspace:apps/happy-blocks provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/block-editor and some of its descendants request"
- level: discard
pattern: "happy-blocks@workspace:apps/happy-blocks provides react (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "happy-blocks@workspace:apps/happy-blocks provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "@automattic/wpcom-block-editor@workspace:apps/wpcom-block-editor provides react (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "@automattic/wpcom-editing-toolkit@workspace:apps/editing-toolkit provides react (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "@automattic/tour-kit@workspace:packages/tour-kit *provides react (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "wp-calypso@workspace:. provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "calypso@workspace:client provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "@automattic/domain-picker@workspace:packages/domain-picker *provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "@automattic/o2-blocks@workspace:apps/o2-blocks provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "@automattic/onboarding@workspace:packages/onboarding *provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "@automattic/page-pattern-modal@workspace:packages/page-pattern-modal *provides react (*) with version 17.0.2, which doesn't satisfy what @wordpress/block-editor and some of its descendants request"
- level: discard
pattern: "@automattic/page-pattern-modal@workspace:packages/page-pattern-modal *provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/block-editor and some of its descendants request"
- level: discard
pattern: "@automattic/page-pattern-modal@workspace:packages/page-pattern-modal *provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "@automattic/search@workspace:packages/search *provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "@automattic/social-previews@workspace:packages/social-previews *provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "@automattic/wpcom-block-editor@workspace:apps/wpcom-block-editor provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "@automattic/wpcom-editing-toolkit@workspace:apps/editing-toolkit provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "@automattic/tour-kit@workspace:packages/tour-kit *provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "calypso@workspace:client provides react (pf0c51) with version 17.0.2, which doesn't satisfy what @automattic/components and some of its descendants request"
- level: discard
pattern: "wp-calypso@workspace:. provides react (p08767) with version 17.0.2, which doesn't satisfy what @automattic/components and some of its descendants request"
- level: discard
pattern: "calypso@workspace:client provides react-dom (p69c5d) with version 17.0.2, which doesn't satisfy what @automattic/components and some of its descendants request"
- level: discard
pattern: "wp-calypso@workspace:. provides react-dom (pff688) with version 17.0.2, which doesn't satisfy what @automattic/components and some of its descendants request"
- level: discard
pattern: "@automattic/wpcom-editing-toolkit@workspace:apps/editing-toolkit provides eslint (pcb2ba) with version 8.6.0, which doesn't satisfy what @wordpress/eslint-plugin and some of its descendants request"
- level: discard
pattern: "wp-calypso@workspace:. provides eslint (p3918c) with version 8.6.0, which doesn't satisfy what @wordpress/eslint-plugin and some of its descendants request"
- level: discard
pattern: "@react-spring/core@npm:9.3.0 * lists build scripts, but its build has been explicitly disabled through configuration."
- level: discard
pattern: "@automattic/global-styles@workspace:packages/global-styles provides react (*) with version 17.0.2, which doesn't satisfy what @wordpress/block-editor and some of its descendants request"
- level: discard
pattern: "@automattic/global-styles@workspace:packages/global-styles provides react (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "@automattic/global-styles@workspace:packages/global-styles provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/block-editor and some of its descendants request"
- level: discard
pattern: "@automattic/global-styles@workspace:packages/global-styles provides react-dom (*) with version 17.0.2, which doesn't satisfy what @wordpress/components and some of its descendants request"
- level: discard
pattern: "@wordpress/data-controls@npm:2.27.0 doesn't provide react (p90380), requested by @wordpress/data"
pattern: "@automattic/wpcom-editing-toolkit@workspace:apps/editing-toolkit provides +(react|react-dom) (*) with version 18.2.0, which doesn't satisfy what @automattic/newspack-blocks and some of its descendants request"

# WordPress packages often have transitive dependencies with incorrect react-related peer dependencies.
# This matcher discards those log messages, while allowing non-react or non-wordpress related violations
# to be handled separately. (For example, npm packages can be handled via packageExtensions.)
#
# WordPress will need to update/change the following packages to versions which include React 18 support,
# and then we'll need to update to those WordPress package versions before we can remove this.
# - react-autosize-textarea@npm:7.1.0
# - reakit-system@npm:0.15.2
# - reakit-utils@npm:0.15.2
# - reakit-warning@npm:0.6.2
# - reakit@npm:1.3.11
#
# The matcher works like so:
# 1. Match any workspace package, such as @automattic/global-styles@workspace, calypso@workspace, happy-blocks@workspace
# 2. Match any path within the workspace, such as @workspace:packages/page-pattern-modal [cd6b3], @workspace::apps/editing-toolkit, @workspace:client, or @workspace:.
# 3. Match a react or react-dom on the current version which a workspace package provides.
# 4. Match only violations coming from within @wordpress packages.
- level: discard
pattern: "**@workspace:+(client|*/*|.) provides +(react|react-dom) (*) with version 18.2.0, which doesn't satisfy what +(@wordpress/*|@types/wordpress__*) and some of its descendants request"

# TODO: Remove this once Reakit can be removed (or once Reakit includes React 18 as a peer dependency.)
- level: discard
pattern: "@wordpress/notices@npm:3.27.0 doesn't provide react (pcdad4), requested by @wordpress/data"
pattern: "calypso@workspace:client provides +(react|react-dom) (*) with version 18.2.0, which doesn't satisfy what reakit and some of its descendants request"

# TODO: Remove this once the react-easy-crop transitive dependency can be removed. (Likely after updating @wordpress/block-editor to a newer version.)
- level: discard
pattern: "calypso@workspace:client provides @wordpress/data (pd64ed) with version 7.6.0, which doesn't satisfy what @automattic/subscription-manager requests"
pattern: "calypso@workspace:client provides +(react|react-dom) (*) with version 18.2.0, which doesn't satisfy what @automattic/block-renderer and some of its descendants request"

nodeLinker: node-modules
# React day picker version 7 does not include explicit react 18 support, but we can't update to v8 just yet.
# TODO: Remove after updating to react-day-picker version 8.
- level: discard
pattern: "calypso@workspace:client provides react (*) with version 18.2.0, which doesn't satisfy what react-day-picker requests"

### Package extensions to provide missing peer dependencies. ###
packageExtensions:
"@automattic/newspack-blocks@*":
peerDependencies:
Expand All @@ -125,13 +62,19 @@ packageExtensions:
"@signal-noise/stylelint-scales@2.0.3":
peerDependencies:
postcss: "*"
"@types/wordpress__components@14.0.10":
"@types/wordpress__components@23.0.1":
peerDependencies:
react: "*"
"@types/wordpress__plugins@3.0.0":
peerDependencies:
react: "*"
"@wordpress/stylelint-config@21.10.0":
"@wordpress/data-controls@2.23.0":
peerDependencies:
react: "*"
"@wordpress/notices@3.23.0":
peerDependencies:
react: "*"
"@wordpress/stylelint-config@21.6.0":
peerDependencies:
postcss: "*"
fake-indexeddb@3.1.7:
Expand All @@ -143,9 +86,6 @@ packageExtensions:
moment: "*"
react: "*"
react-dom: "*"
react-with-styles@3.2.3:
peerDependencies:
react-dom: "*"
reakit-warning@0.6.2:
peerDependencies:
react-dom: "*"
Expand All @@ -160,11 +100,3 @@ packageExtensions:
peerDependencies:
core-js-bundle: "*"
regenerator-runtime: "*"

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

preferAggregateCacheInfo: true

yarnPath: .yarn/releases/yarn-3.2.3.cjs
6 changes: 3 additions & 3 deletions apps/blaze-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
"moment": "^2.26.0",
"page": "^1.11.5",
"prop-types": "^15.8.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^8.0.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.7",
"redux": "^4.2.1",
"redux-thunk": "^2.4.2",
"wpcom": "workspace:^",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function PagePatternsPlugin( props: PagePatternsPluginProps ) {
);

const insertPattern = useCallback(
( title, blocks ) => {
( title: string | null, blocks: unknown[] ) => {
// Add filter to let the tracking library know we are inserting a template.
addFilter( INSERTING_HOOK_NAME, INSERTING_HOOK_NAMESPACE, () => true );

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
declare module '@wordpress/edit-post' {
export const __experimentalMainDashboardButton: React.ComponentType;
export const __experimentalMainDashboardButton: React.ComponentType< {
children?: React.ReactNode;
} >;
}
Loading
Loading