When component is rendered with data, graph is not drawn
We have used the component in the following manner:
class AudioVisualization extends React.Component<AudioVisualizationProps, {}> {
// More logic here...
render() {
const { currentAudioData, audioMarkerPosition, audioPlaying } = this.props;
return currentAudioData ? (
<AudioVisualizationWrapper onClick={this.playPauseAudio}>
<Waveform
buffer={ currentAudioData.audioBuffer }
height={visualizationSize.height}
markerStyle={{
color: "#85C412",
width: 2
}}
onPositionChange={(pos: number) => this.markerPositionChanged(pos)}
position={audioMarkerPosition}
responsive={false}
showPosition={true}
waveStyle={{
animate: true,
color: '#652379',
pointWidth: 1
}}
width={visualizationSize.width}
/>
<Sound
url={currentAudioData.audioURL}
autoLoad={true}
playFromPosition={'duration' in currentAudioData.audioBuffer ?
getAudioPlaybackPosition(audioMarkerPosition, currentAudioData.audioBuffer.duration)
: 0
}
playStatus={audioPlaying ? Sound.status.PLAYING : Sound.status.PAUSED}
onPlaying={(sound: any) => this.soundPositionToMarker(sound.position, sound.duration)}
/>
</AudioVisualizationWrapper>
) : null
}
}
When AudioVisualization is first rendered, it shows without the graph itself.

In the image above we can see that the cursor is drawn, but the data is not.
The next time the component is drawn it is displayed correctly (in example when the data changes).
Analysis of the code at runtime showed that the only time in which the data is set in the component is when componentWillReceiveProps but when the component is rendered for the first time this life-cycle hook is never called.
A workaround was to render the component before we have the data, so componentWIllReceiveProps will be called when the buffer props is updated with the data.
React and related packages versions:
yarn list --depth=0 --pattern react
yarn list v1.9.4
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @fortawesome/[email protected]
├─ @svgr/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]