Home > database >  Change value when is uploaded reactjs
Change value when is uploaded reactjs

Time:11-17

So I'm making a code that receive value from python scripts, it works, If you console it you can the the value.

    fetch('/upload', {
        method: 'POST',
        body: data

    }).then(response => response.json()
    ).then(json => {
        setData(json)
        console.log(json)
    });

And I have this too

        <textarea id="text">
            {data}
        </textarea>

The problem is that when the code works and console the value, nothing appears in the textarea, how can I refresh the text area when the fetch happen.

CodePudding user response:

const [data, setData] = useState("")

<textarea value={data}/>

  • Related