Skip to content

Commit

Permalink
upgrade to react 19
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Apr 26, 2024
1 parent 3f6711c commit 80a20a2
Show file tree
Hide file tree
Showing 29 changed files with 548 additions and 418 deletions.
3 changes: 1 addition & 2 deletions epicshop/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { type PlaywrightTestConfig } from '@playwright/test'
import { devices } from '@playwright/test'
import { type PlaywrightTestConfig , devices } from '@playwright/test'
import 'dotenv/config'

const PORT = process.env.PORT || 3000
Expand Down
7 changes: 5 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
/** @type {import('@types/eslint').Linter.Config} */
export default {
files: ['**/*.js', '**/*.ts', '**/*.tsx'],
languageOptions: { parser: await import('@typescript-eslint/parser') },
plugins: {
'@typescript-eslint': (await import('@typescript-eslint/eslint-plugin'))
.default,
'react-hooks': (await import('eslint-plugin-react-hooks')).default,
import: (await import('eslint-plugin-import')).default,
},
rules: {
// playwright requires destructuring in fixtures even if you don't use anything 🤷‍♂️
'no-empty-pattern': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',

'@typescript-eslint/consistent-type-imports': [
'warn',
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, testStep } from '@epic-web/workshop-utils/test'
import { waitFor, within } from '@testing-library/dom'
import { userEvent } from '#shared/user-event.cjs'
import { userEvent } from '@testing-library/user-event'
import '.'

const screen = within(document.body)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, testStep } from '@epic-web/workshop-utils/test'
import { fireEvent, waitFor, within } from '@testing-library/dom'
import { userEvent } from '#shared/user-event.cjs'
import { userEvent } from '@testing-library/user-event'
import '.'

const screen = within(document.body)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, testStep } from '@epic-web/workshop-utils/test'
import { within } from '@testing-library/dom'
import { userEvent } from '#shared/user-event.cjs'
import { userEvent } from '@testing-library/user-event'
import '.'

const screen = within(document.body)
Expand Down
2 changes: 1 addition & 1 deletion exercises/04.slots/02.solution.generic/toggle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createContext, use, useId, useState } from 'react'
import { Switch } from '#shared/switch.tsx'
import { SlotContext } from './slots'
import { Switch } from '#shared/switch.tsx'

type ToggleValue = { on: boolean; toggle: () => void; id: string }
const ToggleContext = createContext<ToggleValue | null>(null)
Expand Down
2 changes: 1 addition & 1 deletion exercises/04.slots/03.problem.prop/toggle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createContext, use, useId, useState } from 'react'
import { Switch } from '#shared/switch.tsx'
import { SlotContext } from './slots'
import { Switch } from '#shared/switch.tsx'

// 🐨 delete all this context stuff
type ToggleValue = { on: boolean; toggle: () => void; id: string }
Expand Down
2 changes: 1 addition & 1 deletion exercises/05.prop-getters/01.problem.collections/app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Switch } from '#shared/switch.tsx'
import { useToggle } from './toggle.tsx'
import { Switch } from '#shared/switch.tsx'

export function App() {
const { on, togglerProps } = useToggle()
Expand Down
2 changes: 1 addition & 1 deletion exercises/05.prop-getters/01.solution.collections/app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Switch } from '#shared/switch.tsx'
import { useToggle } from './toggle.tsx'
import { Switch } from '#shared/switch.tsx'

export function App() {
const { on, togglerProps } = useToggle()
Expand Down
2 changes: 1 addition & 1 deletion exercises/05.prop-getters/02.problem.getters/app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Switch } from '#shared/switch.tsx'
import { useToggle } from './toggle.tsx'
import { Switch } from '#shared/switch.tsx'

export function App() {
// 💣 delete this:
Expand Down
2 changes: 1 addition & 1 deletion exercises/05.prop-getters/02.solution.getters/app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Switch } from '#shared/switch.tsx'
import { useToggle } from './toggle.tsx'
import { Switch } from '#shared/switch.tsx'

export function App() {
const { on, getTogglerProps } = useToggle()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, testStep } from '@epic-web/workshop-utils/test'
import { screen, waitFor } from '@testing-library/dom'
import { userEvent } from '#shared/user-event.cjs'
import { userEvent } from '@testing-library/user-event'
import '.'

const customButton = await testStep('Custom button is rendred', () =>
Expand Down
2 changes: 1 addition & 1 deletion exercises/06.state-initializers/01.problem.initial/app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Switch } from '#shared/switch.tsx'
import { useToggle } from './toggle.tsx'
import { Switch } from '#shared/switch.tsx'

export function App() {
// 🐨 add an initialOn option (set it to true) and get the reset callback from useToggle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Switch } from '#shared/switch.tsx'
import { useToggle } from './toggle.tsx'
import { Switch } from '#shared/switch.tsx'

export function App() {
const { on, getTogglerProps, reset } = useToggle({ initialOn: true })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from 'react'
import { Switch } from '#shared/switch.tsx'
import { useToggle } from './toggle.tsx'
import { Switch } from '#shared/switch.tsx'

export function App() {
const [initialOn, setInitialOn] = useState(true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from 'react'
import { Switch } from '#shared/switch.tsx'
import { useToggle } from './toggle.tsx'
import { Switch } from '#shared/switch.tsx'

export function App() {
const [initialOn, setInitialOn] = useState(true)
Expand Down
2 changes: 1 addition & 1 deletion exercises/07.state-reducer/01.problem/app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from 'react'
import { Switch } from '#shared/switch.tsx'
import { useToggle } from './toggle.tsx'
import { Switch } from '#shared/switch.tsx'

export function App() {
const [timesClicked, setTimesClicked] = useState(0)
Expand Down
2 changes: 1 addition & 1 deletion exercises/07.state-reducer/01.solution/app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from 'react'
import { Switch } from '#shared/switch.tsx'
import { useToggle } from './toggle.tsx'
import { Switch } from '#shared/switch.tsx'

export function App() {
const [timesClicked, setTimesClicked] = useState(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, testStep } from '@epic-web/workshop-utils/test'
import { render, screen } from '@testing-library/react'
import { userEvent } from '#shared/user-event.cjs'
import { userEvent } from '@testing-library/user-event'
import { App } from './app.tsx'

await testStep('can render the app', () => {
Expand Down
2 changes: 1 addition & 1 deletion exercises/07.state-reducer/02.problem.default/app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from 'react'
import { useToggle } from './toggle.tsx'
import { Switch } from '#shared/switch.tsx'
// 🐨 import the toggleReducer
import { useToggle } from './toggle.tsx'

export function App() {
const [timesClicked, setTimesClicked] = useState(0)
Expand Down
2 changes: 1 addition & 1 deletion exercises/07.state-reducer/02.solution.default/app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from 'react'
import { Switch } from '#shared/switch.tsx'
import { toggleReducer, useToggle } from './toggle.tsx'
import { Switch } from '#shared/switch.tsx'

export function App() {
const [timesClicked, setTimesClicked] = useState(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, testStep } from '@epic-web/workshop-utils/test'
import { render, screen } from '@testing-library/react'
import { userEvent } from '#shared/user-event.cjs'
import { userEvent } from '@testing-library/user-event'
import { App } from './app.tsx'

await testStep('can render the app', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, testStep } from '@epic-web/workshop-utils/test'
import { render, screen } from '@testing-library/react'
import { userEvent } from '#shared/user-event.cjs'
import { userEvent } from '@testing-library/user-event'
import { App } from './app.tsx'

await testStep('can render the app', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, testStep } from '@epic-web/workshop-utils/test'
import { render, screen } from '@testing-library/react'
import { userEvent } from '#shared/user-event.cjs'
import { userEvent } from '@testing-library/user-event'
import { Toggle } from './toggle.tsx'

await testStep('can render Toggle with no props', () => {
Expand Down
Loading

0 comments on commit 80a20a2

Please sign in to comment.