In my React component I have a button meant to send some data over AJAX when clicked. I need to happen only the first time, i.e. to disable the button after it\'s first use.
You can try using React Hooks to set the Component State.
import React, { useState } from 'react'; const Button = () => { const [double, setDouble] = useState(false); return ( { // doSomething(); setDouble(true); }} /> ); }; export default Button;
Make sure you are using ^16.7.0-alpha.x version of react and react-dom.
^16.7.0-alpha.x
react
react-dom
Hope this helps you!