Flow Promise This type is incompatible with undefined undefined

Get a warning enter image description here

in line:

enter image description here

Use Flow.js v.0.48.0. Sample code:

...
import { Font, AppLoading } from 'expo';
...
export default class App extends Component {
  async componentDidMount() {
    await Font.loadAsync(fontsStore);
    ...
  }
  ...
}

      

+3


source to share


2 answers


Found solution for the hack:



...
  componentDidMount() {
    this.loadFonts();
  }

  async loadFonts () {
    await Font.loadAsync(fontsStore);

    this.setState({ fontLoaded: true });
  }
...
      

Run code


+3


source


Async is for losers ... it's a promise, so just implement then

and head out to dinner. :)



  componentDidMount () {
    Font.loadAsync({
      'open-sans-bold': require('./assets/fonts/OpenSans-Bold.ttf'),
    }).then(() => this.setState({fontLoaded: true}))
  }
      

Run code


-4


source







All Articles