Fix stereo boolean into DOM console error.
This commit is contained in:
parent
b7c5643506
commit
800495eef1
1 changed files with 6 additions and 2 deletions
|
@ -13,7 +13,7 @@ interface VUMeterProps extends HTMLProps<HTMLCanvasElement> {
|
||||||
range: [number, number];
|
range: [number, number];
|
||||||
greenRange?: [number, number];
|
greenRange?: [number, number];
|
||||||
source: LevelsSource;
|
source: LevelsSource;
|
||||||
stereo: boolean;
|
stereo?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function VUMeter(props: VUMeterProps) {
|
export function VUMeter(props: VUMeterProps) {
|
||||||
|
@ -30,7 +30,7 @@ export function VUMeter(props: VUMeterProps) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const animate = () => {
|
const animate = () => {
|
||||||
if (!isMic || isMicOpen) {
|
if (!isMic || isMicOpen) {
|
||||||
const result = audioEngine.getLevels(props.source, props.stereo);
|
const result = audioEngine.getLevels(props.source, props.stereo ? props.stereo : false);
|
||||||
setPeakL(result[0]);
|
setPeakL(result[0]);
|
||||||
if (props.stereo) {
|
if (props.stereo) {
|
||||||
setPeakR(result[1]);
|
setPeakR(result[1]);
|
||||||
|
@ -120,7 +120,11 @@ export function VUMeter(props: VUMeterProps) {
|
||||||
}
|
}
|
||||||
}, [peakL, peakR, props.range, props.greenRange, props.stereo]);
|
}, [peakL, peakR, props.range, props.greenRange, props.stereo]);
|
||||||
|
|
||||||
|
|
||||||
const { value, range, greenRange, source, ...rest } = props;
|
const { value, range, greenRange, source, ...rest } = props;
|
||||||
|
|
||||||
|
// Can't put boolean values into HTML DOM.
|
||||||
|
delete rest.stereo;
|
||||||
|
|
||||||
return <canvas ref={canvasRef} {...rest} />;
|
return <canvas ref={canvasRef} {...rest} />;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue