Created
November 11, 2024 15:57
-
-
Save sibsfinx/b33ba61b99ad5920886a778aa2903607 to your computer and use it in GitHub Desktop.
React TSX component with state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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— | |
</> | |
), | |
[UiState.ready]: ( | |
<> | |
Ready! | |
</> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment