What is Promise in React JS?
![What is Promise in React JS?](https://sourcebae.com/blog/wp-content/uploads/2023/08/34m9mus03v2zo9agn2bq.png)
class PromiseExample extends Component {
state = {
data: null,
error: null,
loading: true,
};
componentDidMount() {
fetchData()
.then(result => {
this.setState({ data: result, loading: false });
})
.catch(error => {
this.setState({ error: error.message, loading: false });
});
}