Skip to content

A conditional rendering component to improve readability

Notifications You must be signed in to change notification settings

avantstay/avant-case

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

avant-case

A conditional rendering component to improve readability, the nomenclature is based on proposal pattern matching

examples:

default:

<Case>
    <When 
      is={} //boolean variable
      render={() => Element} // a function that returns one or multiple JSX elements
    />
    <When 
      is={} //boolean variable
      render={() => Element} // a function that returns one or multiple JSX elements
    />
</Case>

non exclusive:

<Case nonExclusive>
    ...
</Case>

By default, the Case component get the first truthy condition and return as fast as possible, but sometimes we need to render more than one When conditions, to enable it, just add nonExclusive prop on Case component

About

A conditional rendering component to improve readability

Resources

Stars

Watchers

Forks

Packages

No packages published