it remains undefined and causes errors. how can i fix it?
this one
Please be concrete. When does it become a function "later on" and why and when is it "undefined"?
Show how u initialize and update it
It is initially undefined. Later it becomes a function. const [component, setComponent] = useState(undefined); const [conn, setConn] = useState(undefined); setConn(() => { let ws = new Connection(con => con, data => { component.writeData(data) }, () => { component.dispose(); }) return ws; }
Three back quote is needed for multiple lines instead of one
It was undefined with useState(undefined);
When I receive a websocket data, it says component is undefined. It was undefined, but not anymore.
Обсуждают сегодня