I want to use a text to speech library in React , the library is implemented with pure Javascript and I want to pass a React result which is a text (string) to the functions of this library .
The function with JS :https://codesandbox.io/s/frosty-violet-t494o?file=/src/script.js
//inside script.js
const TextToSpeech = (text) => {
const textEl = document.getElementById("text");
...
};
export default TextToSpeech;
//inside you react component
import TextToSpeech from 'script.js';
//execute the function with your text
const text="whatever text";
TextToSpeech(text)