Please help me out here. I am trying to toggle the faq buttons, basically when button1 is clicked -> state1 is turned true (tooltip is opened) -> button2 is clicked -> state2 is true, state1 is turned false , tooltip closes. This is what I currently have
const App = () => {
const [isOpen, setIsOpen] = useState(false);
const faqTipBtns = ['faqBtn1', 'faqBtn2', 'faqBtn3'];
const FaqtipIcon = (id) => {
return(
<button id = {id}
onClick = {() => toggleFaqTipBtn()}>
<FaqtipIcon isOpen = {isOpen}/>
</button>
)
};
const toggleFaqTipBtn = () => {
{faqTipBtns.map((id) => {
setIsOpen((prev) => !prev)
})}
return (
<form>
<RadioGroup>
<div>
<Radio
id='idA'
label = 'SomeLabel'/>
{FaqtipIcon('idA')}
</div>
{isOpen && (
<div>
<FaqtipContent
isOpen = {isOpen}
content = {<p>Some Content</p>}
/>
</div>
</RadioGroup>
</form>
)
}
2
Answers
Is this what you’re looking for where you want to toggle the buttons?
React useState to dynamically toggle multiple buttons
I understand your question like that show tooltip that related of button.
example