-
Notifications
You must be signed in to change notification settings - Fork 49
Phaser 4 (RC-5), Next.js v16 App Router, React v.19 deprecates forwardRef, code cleanup, other fixes #7
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
base: main
Are you sure you want to change the base?
Conversation
but probably better to have PhaserGame take `setCanMoveSprite` directly...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| ref.current = { game: game.current, scene: null }; | ||
| } | ||
|
|
||
| const PhaserGame = ({ ref, onChangeScene }: IPropsPhaserGame) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: React ref Conflict Halts Component Operations.
The component uses ref as a regular prop name instead of using forwardRef. In React, ref is a reserved prop that won't be passed to the component as a regular prop. When <PhaserGame ref={phaserRef} /> is used in App.tsx, the ref parameter will be undefined inside the component, causing all ref operations to fail and breaking the game initialization and scene management functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hallucination: https://react.dev/reference/react/forwardRef
Next.js update
Next.js update
Further iterating on this: #3
Since these templates and requested features (#5) are not a current priority at the moment for the very busy core team, I thought I would help out especially as the previous PR on this was helpful to others despite no merge. As mentioned in the previous PR, it is good to give back when the core team gives us so much.
Updates (from the previous update - see earlier PR #3 linked at the top):
Note
Upgrades to Next.js 16 (App Router), React 19 and Phaser 4, refactors the React–Phaser integration and scenes, and adds modern lint/format/build configs.
next@16with App Router (src/app/*), removepages/*, addlayout.tsxandpage.tsx.react@19/react-dom@19.>=24.phaser@4.0.0-rc.5.GameScenebase class (src/game/scenes/common/GameScene.ts) and refactorMainMenu,Game,GameOverto use it and the sharedEventBus.Boot,Preloader) underscenes/loaders; addutils/configfor shared dimensions.forwardRefpattern with typedrefprop andonChangeScenecallback; dynamic-loadPhaserGamewithssr: false.App.tsxto manage scene changes and sprite movement via the new API.eslint.config.mjs), Prettier (.prettierrc), Tailwind/PostCSS (postcss.config.mjs).next.config.mjswith typednext.config.ts..gitignore; add scripts (start,lint,*-nolog).pnpm-lock.yaml; removepackage-lock.json.Written by Cursor Bugbot for commit f08967d. This will update automatically on new commits. Configure here.