You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
472 B
TypeScript
25 lines
472 B
TypeScript
import { ReactNode } from 'react'
|
|
|
|
export type ConditionalProps = {
|
|
/**
|
|
* the condition to test against
|
|
*/
|
|
condition: boolean
|
|
/**
|
|
* the component to render when condition is true
|
|
*/
|
|
whenTrue: ReactNode
|
|
/**
|
|
* the component to render when condition is false
|
|
*/
|
|
whenFalse: ReactNode
|
|
}
|
|
|
|
export function Conditional({
|
|
condition,
|
|
whenFalse,
|
|
whenTrue,
|
|
}: ConditionalProps) {
|
|
return condition ? whenTrue : whenFalse
|
|
}
|