Redirection if response data has the link

I get a response from API:
{ ‘text’: text,
‘audio_path’: audio_file,
‘self_image’: self_image,
‘page_direct’: page_direct,
‘listen_after_reply’: listen_after_reply }

if page_direct is None, then nothing should happen in frontend, if page_direct has a link it should be redirect on that link.

The data is sent to frontend ReactJS,

I am serving the ReactJS build to streamlit.

  if (data["page_direct"]) {
    console.log("api has page direct", data["page_direct"])
    if (data["page_direct"] !== null && data["page_direct"] !== undefined) {
    window.location.href = data["page_direct"];

I have used this redirect code, but it gets directed into div parent component, not the whole web page