meta-quest / immersive-web-emulator

Browser extension that emulates Meta Quest devices for WebXR development. Lead: Felix Zhang (fe1ix@meta.com)
https://developer.oculus.com/blog/webxr-development-immersive-web-emulator/
MIT License
297 stars 34 forks source link

Performance Enhancements and Best Practices Implementation ✈ #42

Open sanjaiyan-dev opened 8 months ago

sanjaiyan-dev commented 8 months ago

Hi, this PR introduces performance improvements and incorporates some best practices.

1) Change setState functions to update using callbacks. For example, instead of setShowRoomSettings(!showRoomSettings));, use setShowRoomSettings((prevShowRoomSettings) => !prevShowRoomSettings);. This change helps with automatic batching (as recommended in React 18) and is advised by the React JS team itself. For more information, please refer to the following links:

2) Moved independent functions outside the component, which reduces unnecessary memory usage, as their references won't change whenever the component updates.

3) Add decoding="async" to the img tag, which makes the development tool load faster and feel more responsive.