1- import React , { forwardRef , useImperativeHandle , useRef } from 'react' ;
1+ import React , { forwardRef , useImperativeHandle } from 'react' ;
2+ import { StyleSheet , View } from 'react-native' ;
23import styles from './AudioPlayerWaveformViewStyles' ;
34import type {
45 AudioPlayerWaveformViewProps ,
@@ -15,6 +16,8 @@ import {
1516 NativeAudioPlayerWaveformView ,
1617} from './AudioPlayerWaveformViewUtils' ;
1718
19+ const refView = React . createRef < View > ( ) ;
20+
1821function CustomAudioPlayerWaveformView (
1922 {
2023 style,
@@ -38,11 +41,16 @@ function CustomAudioPlayerWaveformView(
3841 } : AudioPlayerWaveformViewProps ,
3942 ref : React . Ref < AudioPlayerWaveformHandleType >
4043) : React . ReactElement {
41- const refView = useRef ( ) ;
42-
4344 useImperativeHandle ( ref , ( ) => ( {
44- createPlayer : ( withDebug : boolean = false , subscriptionDurationInMilliseconds : number ) => {
45- setUpPlayer ( getViewId ( refView ) , withDebug , subscriptionDurationInMilliseconds ) ;
45+ createPlayer : (
46+ withDebug : boolean = false ,
47+ subscriptionDurationInMilliseconds : number
48+ ) => {
49+ setUpPlayer (
50+ getViewId ( refView ) ,
51+ withDebug ,
52+ subscriptionDurationInMilliseconds
53+ ) ;
4654 } ,
4755 setSource : ( filePath : string , isAmplitudaMode ?: boolean ) => {
4856 setSource ( getViewId ( refView ) , filePath , isAmplitudaMode ) ;
@@ -64,7 +72,7 @@ function CustomAudioPlayerWaveformView(
6472 return (
6573 < NativeAudioPlayerWaveformView
6674 ref = { refView }
67- style = { [ styles . defaultStyle , style ] }
75+ style = { StyleSheet . flatten ( [ styles . defaultStyle , style ] ) }
6876 progress = { progress }
6977 maxProgress = { maxProgress }
7078 visibleProgress = { visibleProgress }
@@ -86,5 +94,6 @@ function CustomAudioPlayerWaveformView(
8694 ) ;
8795}
8896
89- export const AudioPlayerWaveformView : React . ForwardRefExoticComponent < AudioPlayerWaveformViewProps > =
90- forwardRef ( CustomAudioPlayerWaveformView ) ;
97+ export const AudioPlayerWaveformView = forwardRef (
98+ CustomAudioPlayerWaveformView
99+ ) ;
0 commit comments