question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setFullScreen not working in case of React hooks

See original GitHub issue

Hi,

I am trying to use this library with react hooks. I am able to load the content and all events are also working. But somehow setFullscreen method is not working. With pre hook version of react this method is working. below is sample code that i am using. Please note that progress event is working properly here.

export default function App() {

let unityContent = new UnityContent( “Build/Build.json”, “Build/UnityLoader.js” ); const [progression, setProgression] = useState(0);

unityContent.on(“progress”, progressionVal => { setProgression(progressionVal * 100); });

const onFullScreen = () => { unityContent.setFullscreen(true); };

return ( <div> <Unity unityContent={unityContent} /> <button id="fullScreenButton" onClick={onFullScreen}></button> </div> );

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
DanielAudapticcommented, Jan 23, 2020

Thanks AdhamMoussa,

Creating a top component without any hooks and initialize unityContent from there solved the problem.

Many many thanks AdhamMoussa for pointing out the solution! Really thankful!

1reaction
DanielAudapticcommented, Feb 1, 2020

@AdhamMoussa you are correct! That solved my issues and I believe also for #74. Really greatful for the assistance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

setFullScreen not working in case of React hooks #74 - GitHub
Hi, I am trying to use this library with react hooks. I am able to load the content and all events are also...
Read more >
reactjs - React + Hooks: Change State on ESC Press while in ...
While I have that figured out, I am not able to update the state when I'm pressing ESC to leave the Fullscreen. import...
Read more >
react-full-screen - npm
Component and Hook for handling full screen components. ... Start using react-full-screen in your project by running `npm i ...
Read more >
Reactjs – React 16.7 Hooks : `react.useState` is not a function ...
I am trying functional components with hooks of react 16.7,there is an error: enter image description here. src/components/Footer/index.js
Read more >
Zoom In (FullScreen) PCFs - Dianamics PCF Lady
I have the isFullScreen state inside hook. The important part is the side effect : React.useEffect, which will be called each time the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found