speechmatics / speechmatics-js-sdk

Javascript and Typescript SDK for Speechmatics
MIT License
39 stars 4 forks source link

Compute audioDeviceId instead of useEffect #12

Closed penx closed 9 months ago

penx commented 9 months ago

Removing unnecessary Effects will make your code easier to follow, faster to run, and less error-prone https://react.dev/learn/you-might-not-need-an-effect

The current usage of useEffect falls under "Updating state based on props or state" and is not necessary.

https://react.dev/learn/you-might-not-need-an-effect#updating-state-based-on-props-or-state

Using useEffect means an additional render.