'can't call function inside <script> ReactJS
A simple example from w3school:
<form>
Select a fruit:
<select id="mySelect" size="4">
<option>Apple</option>
<option>Pear</option>
<option>Banana</option>
<option>Orange</option>
</select>
</form>
<script type = "text/javascript">
function myFunction() {
var x = document.getElementById("mySelect") <---ERROR on var "Expression expected.ts(1109)"
x.remove(x.selectedIndex);
} <---ERROR on }"Unexpected token. Did you mean `{'}'}` or `}`?ts(1381)"
</script>
<button onclick={myFunction()}>Remove selected fruit</button>
but when i try to implement it I get the errors mentioned above, everything inside the script-tag is also white unless i put it inside curly brackets. I reckon this means the code doesn't complie?
I have tried installing earlier versions of typeScript but with no success.
Any help would be appreciated!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
