I have a quick question about two different implementations of code in a react native app. I'd like to know if and why one is considered better than the other and why.
#1 uses a standard setTimeout within componentDidMount() like so:
componentDidMount() {
  setTimeout(() => {
    this.setState({ editable: true });
  }, 2000);
}
The second one also involves waiting, but looks like this:
const wait = (timeout) => {
  return new Promise(resolve => setTimeout(resolve, timeout));
}
componentDidMount() {
  wait(2000).then(() => {
    this.setState({ editable: true });
  });
}
Does the second implementation do something the first does not? Is one more robust than the other?
 
    