Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6880e42

Browse filesBrowse files
committed
readme update
1 parent 1669038 commit 6880e42
Copy full SHA for 6880e42

File tree

Expand file treeCollapse file tree

2 files changed

+6
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-4
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,12 @@ You don't have to emit this event if you don't need to access the specific scene
106106
Here's an example of how to access Phaser data for use in a React Component:
107107

108108
```js
109+
import { useRef } from 'react';
110+
109111
// In a parent component
110112
const ReactComponent = () => {
111113

112-
const phaserRef = ref(); // you can access to this ref from phaserRef.current
114+
const phaserRef = useRef(); // you can access to this ref from phaserRef.current
113115

114116
const onCurrentActiveScene = (scene) => {
115117

@@ -126,9 +128,9 @@ const ReactComponent = () => {
126128
}
127129
```
128130

129-
In the code above, you can get a reference to the current Phaser Game instance and the current Scene by calling `ref()`.
131+
In the code above, you can get a reference to the current Phaser Game instance and the current Scene by creating a reference with `useRef()` and assign to PhaserGame component.
130132

131-
From this state reference, the game instance is available via `toRaw(phaserRef.value.game)` and the most recently active Scene via `toRaw(phaserRef.value.scene)`
133+
From this state reference, the game instance is available via `phaserRef.current.game` and the most recently active Scene via `phaserRef.current.scene`.
132134

133135
The `onCurrentActiveScene` callback will also be invoked whenever the the Phaser Scene changes, as long as you emit the event via the EventBus, as outlined above.
134136

‎src/game/PhaserGame.jsx

Copy file name to clipboardExpand all lines: src/game/PhaserGame.jsx
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import { forwardRef, useEffect, useLayoutEffect, useRef } from 'react';
3-
import StartGame from "./main"
3+
import StartGame from './main';
44
import { EventBus } from './EventBus';
55

66
export const PhaserGame = forwardRef(function PhaserGame ({ currentActiveScene }, ref)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.