Skip to content
Advertisement

null reference exception while passing event handler in react

i want to send message while typing text by using websocket.

but have websocket reference error while typing text.

i think ShareTextComponent onInputEvent function parameter is not exeucte in another location.

so websocket property can’t reference in this field

but i don’t know how can i fix it.

and i didn’t use any state management library such as redux and mobx.

just pure reactjs

[error]

enter image description here

[code]

JavaScript

[after logging in onTextInput]

enter image description here

Advertisement

Answer

Add a null check to the top of the function ->

JavaScript

This will at least help you get past that error and narrow down the rest of the flow.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement