'react : Textarea.js:16 Uncaught TypeError: Cannot read properties of undefined (reading 'toUpperCase') at onUpClick (Textarea.js:16:1)
i was trying to make a textbox that converts the text into upper case and i am facing errors in the console like this: "Textarea.js:16 Uncaught TypeError: Cannot read properties of undefined (reading 'toUpperCase') at onUpClick (Textarea.js:16:1)" can someone please tell me wheere did i go wrong!
Solution 1:[1]
Change onClick in your button to <button onClick={e => onUpClick()} ... becouse <button onClick={onUpClick} ..> triggers once the component mount and then it will call toUpperCase() where the text is undefined
Or you could just in your useState do this useState("") set an initial value to it insted of undefined
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
