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

feat(project): update project to use React 18 #2661

Merged
merged 37 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ec8089a
chore(project): add script to set react version
joshblack Dec 6, 2022
175714e
chore: add ci check for test and type-check
joshblack Dec 6, 2022
b4c872b
chore: update workflow syntax
joshblack Dec 6, 2022
4b59e81
chore: update install step
joshblack Dec 6, 2022
61f9730
chore: add fail-fast option
joshblack Dec 6, 2022
8e77628
chore: add types packages to set-react-version
joshblack Dec 6, 2022
f1ff3ec
refactor(project): update TypeScript definitions for React 18
joshblack Dec 7, 2022
89a38c6
chore: update slots types
joshblack Dec 7, 2022
987964b
chore: add ts-ignore for package that needs to be updated for react 18
joshblack Dec 7, 2022
d051d9c
chore: add changeset
joshblack Dec 7, 2022
474cac4
chore: update ActionMenu story to use React.createElement
joshblack Dec 8, 2022
442fd91
chore: update unused import
joshblack Dec 9, 2022
70acaf1
test(ThemeProvider): update test to use userEvents
joshblack Dec 8, 2022
4140673
test(helpers): add TextEncoder for useMedia
joshblack Dec 8, 2022
b4b2a8d
test(MarkdownEditor): update tests for MarkdownEditor
joshblack Dec 9, 2022
b2d5520
test: update TextInputWithTokens test
joshblack Dec 9, 2022
58f0102
test(MarkdownEditor): enable skipped tests
joshblack Dec 9, 2022
23ec248
chore: add spy for console.error() in test
joshblack Dec 12, 2022
3feefab
chore: add globals for react version
joshblack Dec 12, 2022
914d222
chore: remove storybook-addon-html
joshblack Dec 9, 2022
6385ace
chore: update storybook deps
joshblack Dec 9, 2022
976d26f
chore: remove conditional install step from ci.yml
joshblack Dec 9, 2022
325345f
Revert "chore: remove conditional install step from ci.yml"
joshblack Dec 9, 2022
5b4850b
feat(project): update to React 18 for development
joshblack Dec 9, 2022
fa1a5a9
ci: update install step to use 18 by default
joshblack Dec 9, 2022
0d77e0c
chore: update lockfile
joshblack Dec 9, 2022
3f1504d
chore: update eslint to warn on useSSRSafeId
joshblack Dec 9, 2022
013bfdc
feat(project): add useId hook
joshblack Dec 9, 2022
c4c4221
feat(project): update useSSRSafeId to useId
joshblack Dec 9, 2022
4cc7e2e
chore: disable eslint violations
joshblack Dec 9, 2022
5aa9a4d
test: map useId() to useSSRSafeId() in test
joshblack Dec 12, 2022
6d78c16
test(storybook): update interaction tests for UnderlineNav
joshblack Dec 13, 2022
1efba24
chore: add changeset
joshblack Dec 13, 2022
f8bc3c0
Merge branch 'main' of github.com:primer/react into ci/add-react-18-test
joshblack Dec 16, 2022
2e99494
fix(PageHeader): add PropsWithChildren to ParentLinkProps
joshblack Dec 16, 2022
41c96c4
chore: update workflow file
joshblack Dec 16, 2022
9f25f74
chore(eslint): remove inferred type annotation
joshblack Dec 16, 2022
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
5 changes: 5 additions & 0 deletions .changeset/eight-peas-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

Update to React.useId() when using React 18
5 changes: 5 additions & 0 deletions .changeset/strong-dolls-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Update types for components to work for React 17 and 18
13 changes: 13 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,19 @@
{
"ts-ignore": "allow-with-description"
}
],
"no-restricted-imports": [
"error",
{
"paths": [
{
"name": "@react-aria/ssr",
"importNames": ["useSSRSafeId"],
"message": "Please use the `useId` hook from `src/hooks/useId.ts` instead"
}
],
"patterns": []
}
]
}
},
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ jobs:
run: npm run lint

test:
strategy:
fail-fast: false
matrix:
react: [17, 18]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -38,16 +42,30 @@ jobs:
with:
node-version: 16

- name: Set React version
run: node script/set-react-version.js ${{ matrix.react }}

- name: Install dependencies
if: ${{ matrix.react == 17 }}
run: npm install --legacy-peer-deps

- name: Install dependencies
if: ${{ matrix.react == 18 }}
run: npm ci

- name: Build
run: npm run build

- name: Test
run: npm run test -- --coverage
env:
REACT_VERSION_17: ${{ matrix.react == 17 }}

type-check:
strategy:
fail-fast: false
matrix:
react: [17, 18]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -58,7 +76,15 @@ jobs:
with:
node-version: 16

- name: Set React version
run: node script/set-react-version.js ${{ matrix.react }}

- name: Install dependencies
if: ${{ matrix.react == 17 }}
run: npm install --legacy-peer-deps

- name: Install dependencies
if: ${{ matrix.react != 17 }}
run: npm ci

- name: Type check
Expand Down
19 changes: 8 additions & 11 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,26 @@ module.exports = {
{
name: 'storybook-addon-turbo-build',
options: {
optimizationLevel: 2
}
optimizationLevel: 2,
},
},
...(process.env.NODE_ENV === 'production' && process.env.GITHUB_JOB !== 'chromatic'
? ['@whitespace/storybook-addon-html']
: [])
],
core: {
builder: {
name: 'webpack5',
options: {
fsCache: true
}
}
fsCache: true,
},
},
},
features: {
interactionsDebugger: true,
storyStoreV7: true,
buildStoriesJson: true
buildStoriesJson: true,
},
framework: '@storybook/react',
reactOptions: {
fastRefresh: true,
strictMode: true
}
strictMode: true,
},
}
12 changes: 12 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
/* eslint-disable github/unescaped-html-literal */

'use strict'

const {REACT_VERSION_17} = process.env

/**
* @type {import('jest').Config}
*/
module.exports = {
globals: {
REACT_VERSION_LATEST: REACT_VERSION_17 ? REACT_VERSION_17 !== 'true' : true,
REACT_VERSION_17: REACT_VERSION_17 === 'true',
},
testEnvironment: 'jsdom',
cacheDirectory: '.test',
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}', '!src/stories/**', '!**/*.stories.{js,jsx,ts,tsx}'],
Expand Down
Loading