I'm mapping over an array to get the text for each button. I want to map over an array for each button to show text for a mapped array.
So the array for the titles of the button is:
const arr1 = ["one", "two", "three"]
And the text to show when each button is clicked is:
const arr2 = ["button one", "button two", "button three"]
So I want button with the text "one" to show the text "button one" as a p tag when clicked.
Here is what I have so far
const myComp = () => {
const arr1 = ['one', 'two', 'three']
const arr2 = ['button one', 'button two', 'button three']
const mapping = () => {
arr2.map((arr) => {
return <p>{arr}</p>
})
}
return (
<>
{arr1.map((data) =>
<button onClick={mapping()}>
{data}
</button>
)}
</>
)