JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react-dom.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui-react/0.81.2/semantic-ui-react.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.2/semantic.min.css" />
<script src="https://unpkg.com/axios@0.15.3/dist/axios.min.js"></script>
<div id="app"></div>
React
const {
Button
} = semanticUIReact
class App extends React.Component {
handleClick = (name) => {
this.refs[name].ref.classList.add('loading');
axios.get('https://simonbreiter.com/wp-json/wp/v2/projects?_embed')
.then(response => {
setTimeout(() => {
this.removeLoading(name)
}, 3000)
})
.catch(error => console.log(error));
}
removeLoading = (name) => {
this.refs[name].ref.classList.remove('loading');
}
render() {
return (
<div>
{[...Array(3)].map((data, index) => {
const btnIndex = index + 1;
return <Button ref={"btn" + btnIndex} className={'btn'} onClick={() => this.handleClick("btn" + btnIndex)}>Button {btnIndex}</Button>
})}
</div>
)
}
}
ReactDOM.render(<App />, document.getElementById('app'));