I am new to React and let's suppose we have the following piece of code.
const showDetails = () => {
console.log('Show details')
}
const template = (
<div>
<h1>Vibility Toggle</h1>
<button onClick={showDetails}>Show details</button>
</div>
)
var app = document.getElementById('app')
ReactDOM.render(template, app)
What I want is to change the button's title from Show Details to Hide Details when it is clicked. So I' ve thinking to get the click event inside the function and change the title by using a ternary operator. How to do that?
Thanks Theo.