For my company's web app, we need to have the local camera's video accessible by both our main video chat interface and our video chat settings popup modal (see screenshot below).

To try to accomplish this, we create tracks in our parent component using
const useMicrophoneAndCameraTracks = createMicrophoneAndCameraTracks(
{ AEC: true, ANS: true },
{ optimizationMode: "motion" }
);
and
const { ready, tracks } = useMicrophoneAndCameraTracks();
From this, our video track is tracks[1], which is used in both our main video chat interface's component and our video chat settings popup modal's <AgoraVideoPlayer /> component (passed in as props).
However, the problem is that we then fail to turn off the camera (and camera light) after we dismount the parent component:
useEffect(() => {
...
return () => {
for (const track of tracks) {
track.stop();
track.close();
}
}, []);
We do confirm that the camera and camera light does turn off if we only use the track in only one single <AgoraVideoPlayer />
How can we ensure that the light turns off when the parent component is dismounted? Or if this is not the right approach, what should we do instead?