const [buttonState, setButtonState] = useState(true)
setButtonState(!buttonState)
const btn = {
true: { text: 'Show', ... },
false: { text: 'Hide', ... }
}
TS
ругается на Type 'boolean' cannot be used as an index type.
btn[buttonState].text
TS
? btn[String(buttonState) as keyof typeof btn];