HideWhen Component Reference

Table of Contents


Introduction

Syntax

tml`
    <HideWhen hasValue=stateVariable1>
        ...
    </HideWhen>
`tml`
    <HideWhen hasValue="stateVariable1,stateVariable2">
        ...
    </HideWhen>
`
tml`
    <HideWhen hasValue=${SV.find(/stateVariable\d+/)}>
        ...
    </HideWhen>
`

The HideWhen component hides its children whenever any of the state variables specified by the hasValue attribute have truthy values.
Otherwise, the children are rendered.

Usage

HideWhen is often useful in conjunction with ShowWhen to show an error message area when there is an error and show other results when this is no error:
For example:

tml`
    <HideWhen hasValue=myPage_errorMsg>
       <div>Results: {{myPage_results}}</>
    </HideWhen>
    <ShowWhen hasValue=myPage_errorMsg>
       <div>Error: {{myPage_errorMsg}}</>
    </ShowWhen>
`

Attributes

The HideWhen component ignores the standard attributes.

Children

The HideWhen component accepts all children.


DOM element properties

The HideWhen component is remounted when the hasValue conditions change.