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

Update to React 18 #59

Open
wants to merge 81 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
4103bf8
Update all Dependencies to React 18
pirelenito Apr 27, 2022
90abed6
Fixes types in setupHostConfig and createFiberRoot
pirelenito Apr 27, 2022
8c8ee7a
Merge remote-tracking branch 'origin/main' into react-18
pirelenito Jun 30, 2022
b84627e
Get the types of setupHostConfig to be happy
pirelenito Jun 30, 2022
1b351d5
Add concurrent examples
pirelenito Jul 11, 2022
826d04f
Merge remote-tracking branch 'origin/main' into react-18
pirelenito Jul 11, 2022
63c7f2f
New example to compare with deferred mount
pirelenito Jul 11, 2022
27ff459
New hook that allows unwraping into a transition
pirelenito Jul 11, 2022
5c2fb06
Bump to 0.4.0-rc.1
pirelenito Jul 11, 2022
2e8fe70
Everything builds (at least)
pirelenito Jul 11, 2022
c457236
Bump to 0.4.0-rc.2
pirelenito Jul 11, 2022
cc79a81
Add a test watch script
pirelenito Jul 11, 2022
a72a981
Build script in new concurrent examples
pirelenito Jul 18, 2022
c766074
Updates "act" implementation
pirelenito Jul 18, 2022
8b6fc74
Update @testing-library/dom
pirelenito Jul 18, 2022
60155c1
Fixes dom-fiber tests
pirelenito Jul 18, 2022
825e1d3
Restore act on fireEvent functions
pirelenito Jul 18, 2022
92bc653
Merge remote-tracking branch 'origin/main' into react-18
pirelenito Jul 18, 2022
c358a30
Wrap an act around setting a facet
pirelenito Jul 28, 2022
fa876a8
Merge branch 'main' of github.com:Mojang/ore-ui into react-18
Nov 17, 2022
5d4d0e1
feat: updates package versions
Dec 12, 2022
68e1909
Merge branch 'main' of github.com:Mojang/ore-ui into react-18
Dec 12, 2022
0397cdf
debug: adds hide and unhide logs
Dec 12, 2022
d30a4a9
build: update package versions
Dec 15, 2022
389d71d
feat: updates packages and jest
Jan 18, 2023
e0bb50d
feat: synchronises with minecraft-ui branch
Feb 7, 2023
a4a22f2
test: wraps test component with act
Feb 8, 2023
426a222
Merge remote-tracking branch 'origin/main' into react-18
pirelenito Jun 5, 2023
75004e2
Remove unused dependencies and fix one Jest warning
pirelenito Jun 5, 2023
c10d346
Remove junit and sonar reporters
pirelenito Jun 5, 2023
5b2a51d
Fixes lint warings
pirelenito Jun 5, 2023
5acef06
New helper asPromise
pirelenito Jun 5, 2023
7ee4932
Hacking around unwrapping with store and suspense
pirelenito Jun 5, 2023
74fabe3
Cleaning useFacetUnwrap using Suspense
pirelenito Jun 5, 2023
3e3484e
Let’s always defer while unwrapping on Map
pirelenito Jun 5, 2023
c308026
Delete deferred-mount package, as it should no longer be needed
pirelenito Jun 5, 2023
61f7f37
Fix wrong type in useFacetUnwrap
pirelenito Jun 5, 2023
3dbd852
Tweak tests of useFacetUnwrap as it no longer returns NO_VALUE
pirelenito Jun 5, 2023
11e8303
Attempting to write tests for Suspense
pirelenito Jun 5, 2023
5faaa6a
Setting the act environment
pirelenito Jun 5, 2023
43410a8
Upgrade to React 18.2.0
pirelenito Jun 5, 2023
039c3a9
Revert "Setting the act environment"
pirelenito Jun 5, 2023
c39304c
Simple Suspense implementation at the renderer
pirelenito Jun 5, 2023
6057d3a
Make sure asPromise works when there are values immediately
pirelenito Jun 5, 2023
0df0f48
Make mount be deferred by default
pirelenito Jun 5, 2023
9d8aded
Fix unwrap tests
pirelenito Jun 5, 2023
1b3a07b
Merge remote-tracking branch 'origin/main' into react-18
pirelenito Jun 16, 2023
36ee96b
Deprecate useFacetRef
pirelenito Jun 16, 2023
345ce20
Fixing type errors
pirelenito Jun 16, 2023
358e7da
Revert "Deprecate useFacetRef"
pirelenito Oct 27, 2023
99b03b7
Merge remote-tracking branch 'origin/main' into react-18
pirelenito Oct 27, 2023
939711d
Restore deferred-mount and undo Suspense
pirelenito Nov 14, 2023
501fa19
Fix type error after revert
pirelenito Nov 14, 2023
7e1d88c
Update React version of deferred-mount
pirelenito Nov 14, 2023
8b542ed
Update unit test
pirelenito Nov 14, 2023
d87e4ed
Use createRoot on benchmarks
pirelenito Nov 14, 2023
f53d82a
WIP: keeping the deferred-mount API, but using react-18 features
pirelenito Nov 14, 2023
f505c56
Ops, fixing TypeScript issue
pirelenito Nov 14, 2023
5b03b6f
Fixing lint errors
pirelenito Nov 14, 2023
54841da
Fixes how we measure the benchmarks
pirelenito Nov 14, 2023
99b76d6
When comparing we can't expect the same number of events
pirelenito Nov 14, 2023
4921f5c
Remove concurrent example
pirelenito Nov 14, 2023
cc05c4e
Undo changes to the CONTRIBUTING file
pirelenito Nov 14, 2023
ba8b236
With React 18 we can't trigger a render from the body of another comp…
pirelenito Nov 15, 2023
b45cc84
Delete deferred-mount again
pirelenito Nov 15, 2023
57dc192
Update StrictReactNode type
pirelenito Nov 15, 2023
c98cc2a
Small refactor to early bail
pirelenito Dec 12, 2023
2b34893
Addressing performance issue with useFacetWrap
pirelenito Dec 12, 2023
2064456
Uses queueMicroTask when available
pirelenito Dec 18, 2023
46bc790
Update version of eslint-plugin-react-hooks
pirelenito Jan 8, 2024
039ee4e
New hook useFacetWrapMemo
pirelenito Jan 8, 2024
9cae8c2
Use useEffect instead of useLayoutEffect
pirelenito Jan 8, 2024
1108578
Fix for memo wrapping a facet with NO_VALUE
pirelenito Jan 9, 2024
5904ab8
Fix incorrect initial values with useFacetMemo.
marlonicus Jan 11, 2024
1ebf535
Update unit tests for the mapFacets
pirelenito Jan 16, 2024
66bc363
Add skipped test for future improvement to createFacet.
marlonicus Jan 17, 2024
0efae31
Improve and fix unit tests.
marlonicus Jan 17, 2024
1a98134
Remove scheduler from dom-fiber package.
marlonicus Jan 17, 2024
1069c89
Remove reference to scheduler.
marlonicus Jan 17, 2024
e22975d
Fix asPromise race condition
pirelenito Apr 10, 2024
88ae92e
Merge branch 'main' of github.com:Mojang/ore-ui into react-18-main
marlonicus Aug 12, 2024
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
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = function (api) {
api.cache.forever()

return {
presets: ['@babel/preset-typescript'],
plugins: ['@babel/plugin-transform-modules-commonjs', '@babel/plugin-transform-react-jsx'],
presets: ['@babel/preset-typescript', '@babel/preset-react'],
plugins: ['@babel/plugin-transform-modules-commonjs'],
}
}
17 changes: 6 additions & 11 deletions examples/benchmarking/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { mkdirpSync } from 'fs-extra'

const ERROR = 10
const ITERATIONS = 10
const SAMPLE_SIZE = 500
const OFFSET_FRAMES = 2
const MINIMUM_SAMPLE_SIZE = 100

mkdirpSync('./tmp')

Expand Down Expand Up @@ -36,7 +35,7 @@ const compare = async (optionA: string, optionB: string, targetRelativePerforman
const filename = path.join(__dirname, './dist', `${example}.html`)
await page.goto(`file://${filename}`)

await timeout(100)
await timeout(1000)

await page.tracing.start({ path: traceFile })

Expand All @@ -46,15 +45,11 @@ const compare = async (optionA: string, optionB: string, targetRelativePerforman

const { traceEvents } = require(traceFile)

const events = traceEvents.filter(
(event: TraceEvent) => event.name === 'FireAnimationFrame' || event.name === 'MinorGC',
)
const sampledEvents = events.slice(OFFSET_FRAMES, SAMPLE_SIZE + OFFSET_FRAMES)

const totalTime = sampledEvents.reduce((total: number, event: TraceEvent) => total + event.dur, 0)
const events = traceEvents.filter((event: TraceEvent) => event.name === 'FunctionCall')
const totalTime = events.reduce((total: number, event: TraceEvent) => total + (event.dur ?? 0), 0)

if (sampledEvents.length !== SAMPLE_SIZE) {
console.log(`Not enough samples. Measured "${events.length}" of target "${SAMPLE_SIZE}".`)
if (events.length < MINIMUM_SAMPLE_SIZE) {
console.log(`Not enough samples. Measured "${events.length}" of target "${MINIMUM_SAMPLE_SIZE}".`)
process.exit(1)
}

Expand Down
4 changes: 2 additions & 2 deletions examples/benchmarking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"@react-facet/shared-facet": "0.6.1",
"@react-facet/spring": "0.6.1",
"ramda": "^0.27.1",
"react": "^16.9.0",
"react-dom": "^16.9.0"
"react": "18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/fs-extra": "^9.0.12",
Expand Down
8 changes: 6 additions & 2 deletions examples/benchmarking/src/listMemoFacet.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useFacetState, Facet, useFacetMap, useFacetEffect, NO_VALUE, Map } from '@react-facet/core'
import { render } from '@react-facet/dom-fiber'
import { createRoot } from '@react-facet/dom-fiber'
import React, { useEffect } from 'react'

interface Data {
Expand Down Expand Up @@ -103,4 +103,8 @@ const dataEqualityCheck = () => {
}

document.body.innerHTML = '<div id="root"/>'
render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element !== null) {
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/listMemoState.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from 'react-dom'
import { createRoot } from 'react-dom/client'
import React, { useEffect, useState, memo } from 'react'

interface Data {
Expand Down Expand Up @@ -65,4 +65,8 @@ const ListItem = memo(({ health, name }: Data) => {
const randomWork = (name: string | number) => Math.random()

document.body.innerHTML = '<div id="root"/>'
render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element !== null) {
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/markerFacet.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react'
import { render } from '@react-facet/dom-fiber'
import { createRoot } from '@react-facet/dom-fiber'
import { useFacetState, Facet, useFacetMap, NO_VALUE, Map } from '@react-facet/core'
import { times } from 'ramda'

Expand Down Expand Up @@ -63,4 +63,8 @@ function Performance() {
}

document.body.innerHTML = '<div id="root"/>'
render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element !== null) {
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/markerFacetNumber.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react'
import { render } from '@react-facet/dom-fiber'
import { createRoot } from '@react-facet/dom-fiber'
import { useFacetState, Facet, useFacetMap, NO_VALUE, Map } from '@react-facet/core'
import { times } from 'ramda'

Expand Down Expand Up @@ -63,4 +63,8 @@ function Performance() {
}

document.body.innerHTML = '<div id="root"/>'
render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element !== null) {
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/markerState.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from 'react-dom'
import { createRoot } from 'react-dom/client'
import React, { useEffect, useState } from 'react'
import { times } from 'ramda'

Expand Down Expand Up @@ -61,4 +61,8 @@ function Performance() {
}

document.body.innerHTML = '<div id="root"/>'
render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element !== null) {
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/mountFacetDomFiber.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from '@react-facet/dom-fiber'
import { createRoot } from '@react-facet/dom-fiber'
import { times } from 'ramda'
import React, { useEffect, useState } from 'react'

Expand Down Expand Up @@ -54,4 +54,8 @@ const ComplexComponent = ({ value }: { value: number }) => {
}

document.body.innerHTML = '<div id="root"/>'
render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element !== null) {
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/mountReactDom.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from 'react-dom'
import { createRoot } from 'react-dom/client'
import { times } from 'ramda'
import React, { useEffect, useState } from 'react'

Expand Down Expand Up @@ -54,4 +54,8 @@ const ComplexComponent = ({ value }: { value: number }) => {
}

document.body.innerHTML = '<div id="root"/>'
render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element !== null) {
const root = createRoot(element)
root.render(<Performance />)
}
10 changes: 7 additions & 3 deletions examples/benchmarking/src/overheadFacet.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from '@react-facet/dom-fiber'
import { createRoot } from '@react-facet/dom-fiber'
import { useFacetState, useFacetEffect } from '@react-facet/core'
import React, { useEffect } from 'react'

Expand Down Expand Up @@ -31,5 +31,9 @@ function Performance() {
return null
}

document.body.innerHTML = `<div id="root"></div>`
render(<Performance />, document.getElementById('root'))
document.body.innerHTML = '<div id="root"/>'
const element = document.getElementById('root')
if (element !== null) {
const root = createRoot(element)
root.render(<Performance />)
}
10 changes: 7 additions & 3 deletions examples/benchmarking/src/overheadState.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from 'react-dom'
import { createRoot } from 'react-dom/client'
import React, { useEffect, useState } from 'react'

function Performance() {
Expand Down Expand Up @@ -26,5 +26,9 @@ function Performance() {
return null
}

document.body.innerHTML = `<div id="root"></div>`
render(<Performance />, document.getElementById('root'))
document.body.innerHTML = '<div id="root"/>'
const element = document.getElementById('root')
if (element !== null) {
const root = createRoot(element)
root.render(<Performance />)
}
12 changes: 8 additions & 4 deletions examples/benchmarking/src/progressBarFacet.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react'
import { useFacetMap, Facet, useFacetState } from '@react-facet/core'
import { render } from '@react-facet/dom-fiber'
import { createRoot } from '@react-facet/dom-fiber'

const ProgressBar = ({ progress }: { progress: Facet<number> }) => {
const width = useFacetMap((progress) => `${progress * 20}px`, [], [progress])
Expand All @@ -18,7 +18,7 @@ const ProgressBar = ({ progress }: { progress: Facet<number> }) => {
)
}

const App = () => {
const Performance = () => {
const [progress, setProgress] = useFacetState(0)

useEffect(() => {
Expand All @@ -39,5 +39,9 @@ const App = () => {
return <ProgressBar progress={progress} />
}

document.body.innerHTML = `<div id="root"></div>`
render(<App />, document.getElementById('root'))
document.body.innerHTML = '<div id="root"/>'
const element = document.getElementById('root')
if (element !== null) {
const root = createRoot(element)
root.render(<Performance />)
}
12 changes: 8 additions & 4 deletions examples/benchmarking/src/progressBarState.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'
import { render } from 'react-dom'
import { createRoot } from 'react-dom/client'

const ProgressBar = ({ progress }: { progress: number }) => {
const width = `${progress * 20}px`
Expand All @@ -17,7 +17,7 @@ const ProgressBar = ({ progress }: { progress: number }) => {
)
}

const App = () => {
const Performance = () => {
const [progress, setProgress] = useState(0)

useEffect(() => {
Expand All @@ -38,5 +38,9 @@ const App = () => {
return <ProgressBar progress={progress} />
}

document.body.innerHTML = `<div id="root"></div>`
render(<App />, document.getElementById('root'))
document.body.innerHTML = '<div id="root"/>'
const element = document.getElementById('root')
if (element !== null) {
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/toggleRealisticClassFacet.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from '@react-facet/dom-fiber'
import { createRoot } from '@react-facet/dom-fiber'
import { useFacetState } from '@react-facet/core'
import React, { useEffect } from 'react'

Expand Down Expand Up @@ -59,4 +59,8 @@ document.body.innerHTML = `
</style>
`

render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element !== null) {
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/toggleRealisticClassState.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from 'react-dom'
import { createRoot } from 'react-dom/client'
import React, { useEffect, useState } from 'react'

function Performance() {
Expand Down Expand Up @@ -58,4 +58,8 @@ document.body.innerHTML = `
</style>
`

render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element !== null) {
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/toggleSimpleClassFacet.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from '@react-facet/dom-fiber'
import { createRoot } from '@react-facet/dom-fiber'
import { useFacetState } from '@react-facet/core'
import React, { useEffect } from 'react'

Expand Down Expand Up @@ -37,4 +37,8 @@ document.body.innerHTML = `
</style>
`

render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element !== null) {
const root = createRoot(element)
root.render(<Performance />)
}
8 changes: 6 additions & 2 deletions examples/benchmarking/src/toggleSimpleClassState.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from 'react-dom'
import { createRoot } from 'react-dom/client'
import React, { useEffect, useState } from 'react'

function Performance() {
Expand Down Expand Up @@ -36,4 +36,8 @@ document.body.innerHTML = `
</style>
`

render(<Performance />, document.getElementById('root'))
const element = document.getElementById('root')
if (element !== null) {
const root = createRoot(element)
root.render(<Performance />)
}
6 changes: 3 additions & 3 deletions jest.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

// Base Jest configuration for individual projects. Use this as a starting point for your package config
module.exports = {
testEnvironment: 'jsdom',
testEnvironmentOptions: { url: 'http://localhost' },
watchPathIgnorePatterns: ['<rootDir>/dist/'],
testResultsProcessor: '<rootDir>/../../../jest.testResultsProcessor.js',
moduleFileExtensions: ['tsx', 'js', 'ts'],
testMatch: ['**/?(*.)+(spec|test).js?(x)', '**/?(*.)+(spec|test).ts?(x)'],
setupFilesAfterEnv: ['<rootDir>/../../../jest.setupTestFrameworkScriptFile.js'],
transform: {
'^.+\\.jsx?$': 'babel-jest',
'^.+\\.tsx?$': 'babel-jest',
'^.+\\.[jt]sx?$': ['babel-jest', { rootMode: 'upward' }],
},
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
}
7 changes: 5 additions & 2 deletions jest.setupTestFrameworkScriptFile.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/* eslint-disable import/no-named-as-default-member */
// eslint-disable-next-line require-in-package/require-in-package
import React from 'react'
import '@testing-library/jest-dom/extend-expect'
const React = require('react')

const matchers = require('@testing-library/jest-dom/extend-expect')

expect.extend(matchers)

// Make useEffect run synchronously to make it easier to test
// TODO: update this to an official solution once available
Expand Down
6 changes: 0 additions & 6 deletions jest.testResultsProcessor.js

This file was deleted.

Loading
Loading