Skip to content

Commit

Permalink
Updated Getting Started for newer version of Expo
Browse files Browse the repository at this point in the history
  • Loading branch information
rmtsrc authored Jul 2, 2019
1 parent 1e7744d commit 611a72e
Showing 1 changed file with 38 additions and 10 deletions.
48 changes: 38 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,47 @@ npm install native-base --save
**Note** <br />
[NativeBase](https://nativebase.io/) uses some custom fonts that can be loaded using **Font.loadAsync**. Check out the [Expo Font documentation](https://docs.expo.io/versions/latest/sdk/font/).
<br />
Syntax <br />

*Install Expo Fonts*
```bash
expo install expo-font
```

*App.js* <br />
```js
// At the top of your file
import { Font } from 'expo';
import React from 'react';
import { Container, Text } from 'native-base';
import * as Font from 'expo-font';
import { Ionicons } from '@expo/vector-icons';

// Later on in your component
async componentDidMount() {
await Font.loadAsync({
'Roboto': require('native-base/Fonts/Roboto.ttf'),
'Roboto_medium': require('native-base/Fonts/Roboto_medium.ttf'),
...Ionicons.font,
});
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
isReady: false,
};
}

async componentDidMount() {
await Font.loadAsync({
Roboto: require('native-base/Fonts/Roboto.ttf'),
Roboto_medium: require('native-base/Fonts/Roboto_medium.ttf'),
...Ionicons.font,
});
this.setState({ isReady: true });
}

render() {
if (!this.state.isReady) {
return <AppLoading />;
}

return (
<Container>
<Text>Open up App.js to start working on your app!</Text>
</Container>
);
}
}
```
<br />
Expand Down

1 comment on commit 611a72e

@kocho
Copy link

@kocho kocho commented on 611a72e Jul 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code does not work for me with expo v33, following the instructions in readme..

npm install native-base --save
expo install expo-font

Please sign in to comment.