SolidJSS
SolidJSโ€ข6mo agoโ€ข
7 replies
Igor Konyakhin

Using 'createMemo' inside JSX (to render things which are only available in sections of UI)

I am trying to figure out how to createMemo for information, which is only relevant to some sections of the UI (which are rendered conditionally). Top-level (typical) createMemo will crash because the data based on which I'd like to compute it is not available in the entire component (but it is guaranteed to be available for some sections when those sections pass conditional rendering).

Self-contained example
Gist: in case array() is not null, we'd like to display UI about it, which includes its sum in two different places. Challenge is to do it without double-computation and code-duplication.
Was this page helpful?