Open tunesmith opened 4 years ago
This ended up easier than I expected - adding a cy = null;
above the render() method cleared the error, although there is probably a better way to make it more idiomatic typescript.
If using hooks / functional component, this seems to work:
export const Chart = (props: any): ReactElement => {
const cyRef = useRef<Cytoscape.Core>();
...
return (
<CytoscapeComponent
cy={(cy): void => {
cyRef.current = cy;
}}
elements={elements}
...
/>
);
The docs indicate this technique for straight jsx:
When I change my component to *.tsx, I get errors like
TS2339: Property 'cy' does not exist on type 'MyApp'.
How can this be adapted so typescript won't complain for the class component?