expo / examples

Example projects that demonstrate how to use Expo APIs and integrate Expo with other popular tools
2.21k stars 862 forks source link

Update with-custom-font example #433

Closed mass2527 closed 10 months ago

mass2527 commented 1 year ago

Improvements

There are 3 things that I want to improve.

1. Inconsistent style

Prettier was not applied to all lines of this example.

2. Not recommended usage of preventAutoHideAsync method

According to the SplashScreen Method section, preventAutoHideAsync method is recommended to be called in global scope without awaiting because otherwise this might be called too late.

However, in this example, preventAutoHideAsync is called inside of useEffect hook. So I updated this.

3. Unhandled error case

If an error occurs while fetching remote fonts, the splash screen should be hidden and the platform default font can be used rather than keep showing splash screen.

Reference

https://docs.expo.dev/develop/user-interface/fonts/#minimal-example