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

chore: Add support new types from React 18 #113

Merged
merged 6 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Support for the new type definitions from Reacr 18 ([#113](https://github.com/vtex-sites/nextjs.store/pull/113)).
filipewl marked this conversation as resolved.
Show resolved Hide resolved
- Creates new Storybook section `BestPractices` ([#101](https://github.com/vtex-sites/nextjs.store/pull/101))
- Applies new local tokens to `OutOfStock` ([#97](https://github.com/vtex-sites/nextjs.store/pull/97))
- Applies new local tokens to `CartItem` ([#102](https://github.com/vtex-sites/nextjs.store/pull/102))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"webpack": "^5.72.0"
},
"resolutions": {
"@types/react": "^17.x"
"@types/react": "^18.x"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the resolutions? Are we using more than one version of React?

Copy link
Member

@eduardoformiga eduardoformiga Jun 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's because the dependencies tree depends on different versions of @types/react and we can indicate the correct version using this resolutions option.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This resolutions field is also new to me, it seems to be yarn-specific (not npm). I found some documentation here: [yarn] Selective dependency resolutions.

Curiously we don't have it for Gatsby. Also there I was able to have TS understand the new React 18 hooks by just adding this configuration to tsconfig.json, but that didn't work here in NextJS.
😞

},
"lint-staged": {
"*.{ts,js,tsx,jsx}": [
Expand Down
8 changes: 1 addition & 7 deletions src/components/sections/Hero/Hero.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { HelmetProvider } from 'react-helmet-async'

import Icon from 'src/components/ui/Icon'

import type { HeroProps } from '.'
Expand All @@ -15,11 +13,7 @@ const story = {
},
}

const Template = ({ ...args }: HeroProps) => (
<HelmetProvider>
<Hero {...args} />
</HelmetProvider>
)
const Template = ({ ...args }: HeroProps) => <Hero {...args} />

export const Primary = Template.bind({})

Expand Down
4 changes: 2 additions & 2 deletions src/sdk/error/ErrorBoundary/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from 'react'
import type { ErrorInfo } from 'react'
import type { ErrorInfo, ReactNode } from 'react'

const getReloads = () =>
Number(window.sessionStorage.getItem('store:reloads') ?? '0')
Expand All @@ -15,7 +15,7 @@ if (typeof window !== 'undefined') {
window.setInterval(() => setReloads(0), 30e3)
}

class ErrorBoundary extends Component {
class ErrorBoundary extends Component<{ children: ReactNode }> {
public state = { hasError: false, error: null }

public static getDerivedStateFromError(error: Error) {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3810,10 +3810,10 @@
dependencies:
"@types/react" "*"

"@types/react@*", "@types/react@^17.x":
version "17.0.44"
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.44.tgz#c3714bd34dd551ab20b8015d9d0dbec812a51ec7"
integrity sha512-Ye0nlw09GeMp2Suh8qoOv0odfgCoowfM/9MG6WeRD60Gq9wS90bdkdRtYbRkNhXOpG4H+YXGvj4wOWhAC0LJ1g==
"@types/react@*", "@types/react@^18.x":
version "18.0.12"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.12.tgz#cdaa209d0a542b3fcf69cf31a03976ec4cdd8840"
integrity sha512-duF1OTASSBQtcigUvhuiTB1Ya3OvSy+xORCiEf20H0P0lzx+/KeVsA99U5UjLXSbyo1DRJDlLKqTeM1ngosqtg==
dependencies:
"@types/prop-types" "*"
"@types/scheduler" "*"
Expand Down