SolidJSS
SolidJS16mo ago
18 replies
KiaClouth

How to reduce undefined judgments

Hey everyone, in this example, because I need to clear the resources occupied by the engine when the component is uninstalled, I defined the engine outside onMount. Since the initialization of the engine requires canvasRef, it is undefined at the beginning. This means that if I need to modify the properties of engine(), I need to check whether it is undefined multiple times. How should I improve it?
image.png
Was this page helpful?