I am new to React and I am trying to change the value of an element every time i click on the button. I look online and I think it should be working but for some reason it's not! thanks in advance
import React from 'react';
import ReactDOM from 'react-dom';
const App = () => {
let showDetails = false;
const visabillty = () => {
showDetails = !showDetails;
};
return (
<div style={{textAlign: 'center', margin: '40px'}}>
<h1>Visailty Project</h1>
<button onClick={visabillty}>
{showDetails ? 'show Details' : 'hide Deatils '}
</button>
<h1> {showDetails ? 'hello' : 'buy'}</h1>
</div>
);
};
ReactDOM.render(<App />, document.getElementById('root'));