Skip to content

Instantly share code, notes, and snippets.

@sibsfinx
Created November 11, 2024 15:57
Show Gist options
  • Save sibsfinx/b33ba61b99ad5920886a778aa2903607 to your computer and use it in GitHub Desktop.
Save sibsfinx/b33ba61b99ad5920886a778aa2903607 to your computer and use it in GitHub Desktop.
React TSX component with state
import React from 'react';
const UiState = {
loading: 'loading',
ready: 'ready'
} as const;
type UiState = typeof UiState[keyof typeof UiState];
const stateList: Record<UiState, React.ReactNode> = {
[UiState.loading]: (
<>
Loading&mdash;
</>
),
[UiState.ready]: (
<>
Ready!
</>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment