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

fix(types): update resizeTo ref type #560

Merged
merged 1 commit into from
Jan 4, 2025
Merged

Conversation

RJWadley
Copy link

@RJWadley RJWadley commented Jan 3, 2025

Description of change

Updates type signature of resizeTo on Application for react 19 compatability

In react 19 useRef requires an argument and the type signature has changed slightly. It's a bit more strict by default, so the type needs to be manually widened in order to work for common use cases like the one in the docs:

import { Application } from '@pixi/react'
import { useRef } from 'react'
const MyComponent = () => {
  const parentRef = useRef<HTMLDivElement>(null) // <- returns RefObject<HTMLDivElement | null>
  return (
    <div ref={parentRef}>
      <Application resizeTo={parentRef} /> 
      {/* ^ will throw an error if we ask for RefObject<HTMLElement> - null is not assignable to element */}
    </div>
  )
}
Pre-Merge Checklist
  • Tests and/or benchmarks are included N/A
  • Documentation is changed or added N/A
  • Lint process passed (npm run lint)
  • Tests passed (npm run test)

Copy link

codesandbox-ci bot commented Jan 3, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 068eec3:

Sandbox Source
pixi.js-sandbox Configuration

@trezy trezy self-requested a review January 4, 2025 05:54
Copy link
Collaborator

@trezy trezy left a comment

Choose a reason for hiding this comment

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

This looks great. Thanks for the PR! ❤️

@trezy trezy added v8 Issues related to Pixi React v8 bug Something isn't working labels Jan 4, 2025
@trezy trezy enabled auto-merge January 4, 2025 05:57
@trezy trezy disabled auto-merge January 4, 2025 06:01
@trezy trezy enabled auto-merge January 4, 2025 06:02
@trezy trezy added this pull request to the merge queue Jan 4, 2025
Merged via the queue into pixijs:beta with commit 60dd9ff Jan 4, 2025
5 checks passed
Copy link

github-actions bot commented Jan 4, 2025

🎉 This PR is included in version 8.0.0-beta.21 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released on @beta v8 Issues related to Pixi React v8
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants