-1

Does using expo react native doesn't allow to install native base ?

2 Answers2

0

No, expo doesn't stop you from using any frontend package, because there is a specific way to install native base after installing native-base. Put the following code in your main react-native file

import React, { Component } from 'react';
import { Root } from 'native-base';
import Main from "project directory";
import * as Font from 'expo-font';
import { ActivityIndicator } from 'react-native';

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = { loading: true };
  }
  async componentDidMount() {
    await Font.loadAsync({
      Roboto: require('native-base/Fonts/Roboto.ttf'),
      Roboto_medium: require('native-base/Fonts/Roboto_medium.ttf'),
    });
    this.setState({ loading: false });
  }
  render() {
    if (this.state.loading) {
      return (
        <Root>
          <ActivityIndicator />
        </Root>
      );
    } else {
      return (
        <Root>
          <Main/>//Your main Javascript project file.
        </Root>
      );
    }
  }
}
David Buck
  • 3,752
  • 35
  • 31
  • 35
0

It is documented in nativebase website. You will have to install expo-font and make some adjustments in App.js. The official documentation link is https://docs.nativebase.io/docs/GetStarted.html#Setup_with_Expo

Haseeb A
  • 5,356
  • 1
  • 30
  • 34