-NPM version 6.4.1
-expo version 2.6.14
-Atom 1.34.0
Problems
- During my development, encounter error as shown below when try to test it on Expo client.
Steps
import { LinearGradient } from 'expo';
import { LinearGradient } from 'expo';
import React, { Component } from "react";
import Expo from "expo";
import HomeScreen from "./src/HomeScreen/index.js";
export default class AwesomeApp extends Component {
constructor() {
super();
this.state = {
isReady: false
};
}
async componentWillMount() {
await Expo.Font.loadAsync({
Roboto: require("native-base/Fonts/Roboto.ttf"),
Roboto_medium: require("native-base/Fonts/Roboto_medium.ttf"),
Ionicons: require("native-base/Fonts/Ionicons.ttf")
});
this.setState({ isReady: true });
}
render() {
if (!this.state.isReady) {
return <Expo.AppLoading />;
}
return <HomeScreen />;
}
}
Steps
...
await Expo.Font.loadAsync({
...
import React, { Component } from "react";
import HomeScreen from "./src/HomeScreen/index.js";
import {Font, Expo, AppLoading} from 'expo';
export default class AwesomeApp extends Component {
state={
isReady: false
}
constructor() {
super();
}
async componentWillMount() {
await Font.loadAsync({
Roboto: require("native-base/Fonts/Roboto.ttf"),
Roboto_medium: require("native-base/Fonts/Roboto_medium.ttf"),
Ionicons: require("native-base/Fonts/Ionicons.ttf")
});
this.setState({ isReady: true });
}
render() {
if (!this.state.isReady) {
return <AppLoading />;
}
return <HomeScreen />;
}
}
import React from "react";
import { AppRegistry, Image, StatusBar } from "react-native";
import { Container, Content, Text, List, ListItem } from "native-base";
const routes = ["Home", "Chat", "Profile"];
export default class SideBar extends React.Component {
render() {
return (
<Container>
<Content>
<Image
source={{
uri: "https://github.com/GeekyAnts/NativeBase-KitchenSink/raw/react-navigation/img/drawer-cover.png"
}}
style={{
height: 120,
alignSelf: "stretch",
justifyContent: "center",
alignItems: "center"
}}>
<Image
square
style={{ height: 80, width: 70 }}
source={{
uri: "https://github.com/GeekyAnts/NativeBase-KitchenSink/raw/react-navigation/img/logo.png"
}}
/>
</Image>
<List
dataArray={routes}
renderRow={data => {
return (
<ListItem
button
onPress={() => this.props.navigation.navigate(data)}>
<Text>{data}</Text>
</ListItem>
);
}}
/>
</Content>
</Container>
);
}
}
Steps
render() {
...
<Image
source={{
uri: "https://github.com/GeekyAnts/NativeBase-KitchenSink/raw/react-navigation/img/drawer-cover.png"
}}
style={{
height: 120,
alignSelf: "stretch",
justifyContent: "center",
alignItems: "center"
}}>
...
);
}
}
import React from "react";
import { AppRegistry, Image, StatusBar, ImageBackground } from "react-native";
import { Container, Content, Text, List, ListItem } from "native-base";
const routes = ["Home", "Chat", "Profile"];
export default class SideBar extends React.Component {
render() {
return (
<Container>
<Content>
<ImageBackground
source={require("../../images/drawer-cover.png")}
style={{
height: 120,
alignSelf: "stretch",
justifyContent: "center",
alignItems: "center"
}}>
<Image
square
style={{ height: 80, width: 70 }}
source={require("../../images/logo.png")}
/>
</ImageBackground>
<List
dataArray={routes}
renderRow={data => {
return (
<ListItem
button
onPress={() => this.props.navigation.navigate(data)}>
<Text>{data}</Text>
</ListItem>
);
}}
/>
</Content>
</Container>
);
}
}
import React, { Component } from 'react';
import { Container, Header, Content, Button, Text } from 'native-base';
import {Font, Expo, AppLoading} from 'expo';
class ButtonSizeExample extends Component {
state={
isReady: false
}
async componentWillMount() {
await Font.loadAsync({
'Roboto': require('native-base/Fonts/Roboto.ttf'),
'Roboto_medium': require('native-base/Fonts/Roboto_medium.ttf'),
});
this.setState({isReady:true})
}
render() {
if (!this.state.isReady) {
return <AppLoading />;
}
return (
<Container>
<Header />
<Content>
/*Small size button*/
<Button small primary>
<Text>Default Small</Text>
</Button>
/*Regular size button*/
<Button success>
<Text>Success Default</Text>
</Button>
/*Large size button*/
<Button large dark>
<Text>Dark Large</Text>
</Button>
</Content>
</Container>
);
}
}
export default ButtonSizeExample;
Steps
return (
<Container>
<Header />
<Content>
/*Small size button*/
...
/*Regular size button*/
...
/*Large size button*/
...
</Content>
</Container>
);
}
}
export default ButtonSizeExample;
import React, { Component } from 'react';
import { Container, Header, Content, Button, Text } from 'native-base';
import {Font, Expo, AppLoading} from 'expo';
class ButtonSizeExample extends Component {
state={
isReady: false
}
async componentWillMount() {
await Font.loadAsync({
'Roboto': require('native-base/Fonts/Roboto.ttf'),
'Roboto_medium': require('native-base/Fonts/Roboto_medium.ttf'),
});
this.setState({isReady:true})
}
render() {
if (!this.state.isReady) {
return <AppLoading />;
}
return (
<Container>
<Header />
<Content>
<Button small primary>
<Text>Default Small</Text>
</Button>
<Button success>
<Text>Success Default</Text>
</Button>
<Button large dark>
<Text>Dark Large</Text>
</Button>
</Content>
</Container>
);
}
}
export default ButtonSizeExample;
import React from "react";
import { Root } from "native-base";
import {createStackNavigator, createAppContainer} from "react-navigation";
import ActionSheetIconExample from './src/component/ActionSheetIconExample';
const NavStack = createStackNavigator(
{
Home: { screen: ActionSheetIconExample }
}
);
const AppNavigator = createAppContainer(NavStack);
export default () =>
<Root>
<AppNavigator />
</Root>;
headerMode: 'none',
import React from "react";
import { Root } from "native-base";
import {createStackNavigator, createAppContainer} from "react-navigation";
import ActionSheetIconExample from './src/component/ActionSheetIconExample';
const NavStack = createStackNavigator(
{
Home: { screen: ActionSheetIconExample }
},
{
headerMode: 'none',
}
);
const AppNavigator = createAppContainer(NavStack);
export default () =>
<Root>
<AppNavigator />
</Root>;