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: Support React 19 #114

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

feat: Support React 19 #114

wants to merge 3 commits into from

Conversation

amannn
Copy link

@amannn amannn commented Dec 6, 2024

No description provided.

@amannn
Copy link
Author

amannn commented Jan 27, 2025

@ZeeCoder Any chance this could be merged and released?

@ZeeCoder
Copy link
Owner

Not without having dedicated tests for React 19 alongside React 18, I'm sorry

@amannn
Copy link
Author

amannn commented Jan 28, 2025

@ZeeCoder I've updated the dev dependency of React to 19 and tests seem to run.

The only thing I had to change was a usage of useRef within the library, to match the updated types of React (which require an argument to useRef), but for consumers it shouldn't make a difference.

Does that look good to you?

@amannn
Copy link
Author

amannn commented Feb 17, 2025

@ZeeCoder Any chance this can be merged & released now after 7a266a2?

@jamesmoss
Copy link

jamesmoss commented Feb 23, 2025

@amannn this still only tests with v19. I can see from @ZeeCoder's comments on #108 he'll want you to update testing.yml with a matrix so 18 and 19 are tested again. I haven't tested these changes but you'll need something like the following (plus update package.json so that both versions are allowed in devDependencies)

name: Testing
on:
  pull_request:
    branches:
      - master
      - alpha
jobs:
  testing:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        react-version: [18, 19]
    env:
      BS_ACCESS_KEY: ${{ secrets.BS_ACCESS_KEY }}
      BS_USERNAME: ${{ secrets.BS_USERNAME }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
      - name: Set up Node
        uses: actions/setup-node@v3
        with:
          always-auth: true
          node-version: 14
      - name: Installing Dependencies
        run: yarn install --frozen-lockfile
      - name: Install React ${{ matrix.react-version }}
        run: yarn add react@${{ matrix.react-version }} react-dom@${{ matrix.react-version }} --dev
      - name: Checking File Size
        run: yarn check:size
      - name: Checking Linting Rules
        run: yarn check:lint
      - name: Checking Types
        run: yarn check:types
      - name: Running Unit Tests
        run: yarn test:unit
      - name: Testing SSR
        run: yarn test:create:ssr
      - name: Testing in Modern Browsers (BrowserStack)
        run: yarn test:bs:modern
      - name: Testing in Legacy Browsers (BrowserStack)
        run: yarn test:bs:legacy

@amannn
Copy link
Author

amannn commented Feb 24, 2025

@jamesmoss Thanks for the suggestion, I've updated the test file accordingly. I think package.json doesn't need to be changed though, as yarn add react@18 would update the file anyway—right?

@ZeeCoder Can you try executing the workflow to see if this works?

@ZeeCoder
Copy link
Owner

I might find some time this Sunday, but not until then unfortunately. Appreciate the effort 🙏

@ZeeCoder ZeeCoder mentioned this pull request Mar 7, 2025
@ZeeCoder
Copy link
Owner

ZeeCoder commented Mar 7, 2025

I'm sorry but I'm really struggling to find the time and give this the attention it deserves.

I managed to work about an hour on this yesterday, and bumped into a bunch of errors (the deps sorely need an upgrade!), like this one:
image

I finally managed to get things running with node v16, but then I got to this error:
image

Seems like the types are not quite right yet, although interestingly the CI would tell you otherwise.
(Type checks passed for both react versions)

The main thing I wanted to check is to just ensure, that if I used the hook with v18, then the types would be compatible with v19 as well, otherwise this'd be a breaking change only supporting v19 and above.

The CI seems to break for reasons not related to the code that I'll need to fix, but in the meantime it's possible to run type checking, size checking and unit tests locally.

@amannn
Copy link
Author

amannn commented Mar 31, 2025

Hey, thanks for looking into this @ZeeCoder! I unfortunately don't have the time currently to dive deeper into this and have therefore decided to add a simple, custom implementation of useResizeObserver in my app instead of this dependency so that I can unblock the React 19 upgrade for me.

If someone else wants to finish this PR, feel free to fork away from the current state on this branch.

@ZeeCoder
Copy link
Owner

The only thing blocking this is that I don't think making the hook support types of both v18 and v19 is trivial.
I might just deploy a new major for v19 exclusively when I get the time as that wouldn't require that much work and there's not as much uncertainty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants