You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Create a callback function for messages from the worker thread.
97
93
constonMessageReceived= (e) => {
@@ -127,7 +123,7 @@ We recommend starting the development server again with `npm run dev`
127
123
128
124
129
125
First, let's define our components. Create a folder called `components` in the `src` directory, and create the following files:
130
-
1. `LanguageSelector.jsx`: This component will allow the user to select the input and output languages. Check out the full list of languages [here](https://github.com/huggingface/transformers.js/blob/main/examples/react-translator/src/components/LanguageSelector.jsx).
126
+
1. `LanguageSelector.jsx`: This component will allow the user to select the input and output languages. Check out the full list of languages [here](https://github.com/huggingface/transformers.js-examples/tree/main/react-translator/src/components/LanguageSelector.jsx).
131
127
```jsx
132
128
constLANGUAGES= {
133
129
"Acehnese (Arabic script)":"ace_Arab",
@@ -363,7 +359,6 @@ Finally, we can add some CSS to make our app look a little nicer. Modify the fol
363
359
z-index:0;
364
360
top:0;
365
361
width:1%;
366
-
height:100%;
367
362
overflow: hidden;
368
363
background-color: #007bff;
369
364
white-space: nowrap;
@@ -402,6 +397,7 @@ First, let's define the `translate` function, which will be called when the user
402
397
```jsx
403
398
consttranslate= () => {
404
399
setDisabled(true);
400
+
setOutput('');
405
401
worker.current.postMessage({
406
402
text: input,
407
403
src_lang: sourceLanguage,
@@ -417,14 +413,14 @@ Now, let's add an event listener in `src/worker.js` to listen for messages from
Finally, let's fill in our `onMessageReceived` function, which will update the application state in response to messages from the worker thread. Add the following code inside the `useEffect` hook we defined earlier:
451
+
Finally, let's fill in our `onMessageReceived` function in `src/App.jsx`, which will update the application state in response to messages from the worker thread. Add the following code inside the `useEffect` hook we defined earlier:
0 commit comments