Skip to content

Commit

Permalink
feat!: React 19
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett committed Mar 28, 2024
1 parent 667cf88 commit ac04310
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 53 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@
"devDependencies": {
"@types/node": "^18.7.14",
"@types/react": "^18.0.17",
"react": "^18.2.0",
"react": "0.0.0-experimental-2b036d3f1-20240327",
"rimraf": "^3.0.2",
"suspend-react": "^0.0.8",
"suspend-react": "^0.1.3",
"typescript": "^4.7.4",
"vite": "^3.0.9",
"vitest": "^0.22.1"
},
"dependencies": {
"@types/react-reconciler": "^0.26.7",
"react-reconciler": "^0.27.0"
"@types/react-reconciler": "^0.28.8",
"react-reconciler": "0.0.0-experimental-2b036d3f1-20240327"
},
"peerDependencies": {
"react": ">=18.0"
"react": ">=19.0"
},
"scripts": {
"build": "rimraf dist && vite build && tsc",
Expand Down
36 changes: 26 additions & 10 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// <reference types="react/experimental" />
import * as React from 'react'
import Reconciler from 'react-reconciler'
import { DefaultEventPriority, ConcurrentRoot } from 'react-reconciler/constants.js'
Expand Down Expand Up @@ -56,10 +57,10 @@ const reconciler = Reconciler<
HostConfig['noTimeout']
>({
isPrimaryRenderer: false,
warnsIfNotActing: false,
supportsMutation: true,
supportsPersistence: false,
supportsHydration: false,
now: Date.now,
scheduleTimeout: setTimeout,
cancelTimeout: clearTimeout,
noTimeout: -1,
Expand Down Expand Up @@ -87,11 +88,30 @@ const reconciler = Reconciler<
resetAfterCommit() {},
preparePortalMount() {},
clearContainer: (container) => (container.head = null),
// @ts-ignore
getCurrentEventPriority: () => DefaultEventPriority,
beforeActiveInstanceBlur: () => {},
afterActiveInstanceBlur: () => {},
detachDeletedInstance: () => {},
getInstanceFromNode() {
throw new Error('Not implemented.')
},
beforeActiveInstanceBlur() {},
afterActiveInstanceBlur() {},
detachDeletedInstance() {},
// @ts-ignore untyped react-experimental options inspired by react-art
// TODO: add shell types for these and upstream to DefinitelyTyped
// https://github.com/facebook/react/blob/main/packages/react-art/src/ReactFiberConfigART.js
shouldAttemptEagerTransition() {
return false
},
requestPostPaintCallback() {},
maySuspendCommit() {
return false
},
preloadInstance() {
return true // true indicates already loaded
},
startSuspendingCommit() {},
suspendInstance() {},
waitForCommitToBeReady() {},
NotPendingTransition: null,
})

// Inject renderer meta into devtools
Expand Down Expand Up @@ -121,11 +141,7 @@ export function createPortal(element: React.ReactNode, container: HostContainer)
return <>{reconciler.createPortal(element, container, null, null)}</>
}

declare module 'react' {
const unstable_act: <T = any>(cb: () => Promise<T>) => Promise<T>
}

/**
* Safely flush async effects when testing, simulating a legacy root.
*/
export const act = React.unstable_act
export const act: <T = any>(cb: () => Promise<T>) => Promise<T> = (React as any).act
59 changes: 21 additions & 38 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf"
integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==

"@types/react-reconciler@^0.26.7":
version "0.26.7"
resolved "https://registry.yarnpkg.com/@types/react-reconciler/-/react-reconciler-0.26.7.tgz#0c4643f30821ae057e401b0d9037e03e8e9b2a36"
integrity sha512-mBDYl8x+oyPX/VBb3E638N0B7xG+SPk/EAMcVPeexqus/5aTpTphQi0curhhshOqRrc9t6OPoJfEUkbymse/lQ==
"@types/react-reconciler@^0.28.8":
version "0.28.8"
resolved "https://registry.yarnpkg.com/@types/react-reconciler/-/react-reconciler-0.28.8.tgz#e51710572bcccf214306833c2438575d310b3e98"
integrity sha512-SN9c4kxXZonFhbX4hJrZy37yw9e7EIxcpHCxQv5JUS18wDE5ovkQKlqQEkufdJCCMfuI9BnjUJvhYeJ9x5Ra7g==
dependencies:
"@types/react" "*"

Expand Down Expand Up @@ -296,23 +296,11 @@ is-core-module@^2.9.0:
dependencies:
has "^1.0.3"

"js-tokens@^3.0.0 || ^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==

local-pkg@^0.4.2:
version "0.4.2"
resolved "https://registry.yarnpkg.com/local-pkg/-/local-pkg-0.4.2.tgz#13107310b77e74a0e513147a131a2ba288176c2f"
integrity sha512-mlERgSPrbxU3BP4qBqAvvwlgW4MTg78iwJdGGnv7kibKjWcJksrG3t6LB5lXI93wXRDvG4NpUgJFmTG4T6rdrg==

loose-envify@^1.1.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
dependencies:
js-tokens "^3.0.0 || ^4.0.0"

loupe@^2.3.1:
version "2.3.4"
resolved "https://registry.yarnpkg.com/loupe/-/loupe-2.3.4.tgz#7e0b9bffc76f148f9be769cb1321d3dcf3cb25f3"
Expand Down Expand Up @@ -373,20 +361,17 @@ postcss@^8.4.16:
picocolors "^1.0.0"
source-map-js "^1.0.2"

react-reconciler@^0.27.0:
version "0.27.0"
resolved "https://registry.yarnpkg.com/react-reconciler/-/react-reconciler-0.27.0.tgz#360124fdf2d76447c7491ee5f0e04503ed9acf5b"
integrity sha512-HmMDKciQjYmBRGuuhIaKA1ba/7a+UsM5FzOZsMO2JYHt9Jh8reCb7j1eDC95NOyUlKM9KRyvdx0flBuDvYSBoA==
react-reconciler@0.0.0-experimental-2b036d3f1-20240327:
version "0.0.0-experimental-2b036d3f1-20240327"
resolved "https://registry.yarnpkg.com/react-reconciler/-/react-reconciler-0.0.0-experimental-2b036d3f1-20240327.tgz#72e31d374166a78d2f483f44629ef5d698e4bf6c"
integrity sha512-PR2i5jvoq9tnVI6eaZV16iQSYlevLvjUP+jb5MrdWgDFN5aYRe0tfgmmoH0UCBuMEDc9BzaRQS2MdvQcgXXXcg==
dependencies:
loose-envify "^1.1.0"
scheduler "^0.21.0"
scheduler "0.0.0-experimental-2b036d3f1-20240327"

react@^18.2.0:
version "18.2.0"
resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"
integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==
dependencies:
loose-envify "^1.1.0"
[email protected]:
version "0.0.0-experimental-2b036d3f1-20240327"
resolved "https://registry.yarnpkg.com/react/-/react-0.0.0-experimental-2b036d3f1-20240327.tgz#0942a915478145debb52057c9c15b21739d87862"
integrity sha512-gXp1gsHJOVnV5cYMTDxTDOw5VuRIuDq1HmCNZJZNAVUaBB1FWjfBaXZIFG8E84kjfkA87xrLl+9qSdzrFUUHZA==

resolve@^1.22.1:
version "1.22.1"
Expand All @@ -411,12 +396,10 @@ rimraf@^3.0.2:
optionalDependencies:
fsevents "~2.3.2"

scheduler@^0.21.0:
version "0.21.0"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.21.0.tgz#6fd2532ff5a6d877b6edb12f00d8ab7e8f308820"
integrity sha512-1r87x5fz9MXqswA2ERLo0EbOAU74DpIUO090gIasYTqlVoJeMcl+Z1Rg7WHz+qtPujhS/hGIt9kxZOYBV3faRQ==
dependencies:
loose-envify "^1.1.0"
[email protected]:
version "0.0.0-experimental-2b036d3f1-20240327"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.0.0-experimental-2b036d3f1-20240327.tgz#d2d5fcc89febd5e6ce9e4fff8e3afd3f1dafb098"
integrity sha512-/rt/j4357yyLvsiceZKo2VKb/ltJJDfdW0ip6Z8VyChG39/qH2kayG1ecFp5Rk4LxtUtoioNG24jJhGXSIvZQA==

source-map-js@^1.0.2:
version "1.0.2"
Expand All @@ -428,10 +411,10 @@ supports-preserve-symlinks-flag@^1.0.0:
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==

suspend-react@^0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/suspend-react/-/suspend-react-0.0.8.tgz#b0740c1386b4eb652f17affe4339915ee268bd31"
integrity sha512-ZC3r8Hu1y0dIThzsGw0RLZplnX9yXwfItcvaIzJc2VQVi8TGyGDlu92syMB5ulybfvGLHAI5Ghzlk23UBPF8xg==
suspend-react@^0.1.3:
version "0.1.3"
resolved "https://registry.yarnpkg.com/suspend-react/-/suspend-react-0.1.3.tgz#a52f49d21cfae9a2fb70bd0c68413d3f9d90768e"
integrity sha512-aqldKgX9aZqpoDp3e8/BZ8Dm7x1pJl+qI3ZKxDN0i/IQTWUwBx/ManmlVJ3wowqbno6c2bmiIfs+Um6LbsjJyQ==

tinypool@^0.2.4:
version "0.2.4"
Expand Down

0 comments on commit ac04310

Please sign in to comment.