React NativeBase not showing my imported components

喜你入骨 提交于 2019-11-29 17:55:34

NativeBase Container as of now mainly accepts Header, Content and Footer.

NativeBase Content in-turn takes Image, View and ScrollView of React Native and not any other custom components.

Thank you for bringing this into notice.

My team will get back to you with the solution.

So I've figured out the issue... It seems like React NativeBase does not allow you to have the <Content> section outside of the main component. Something like this works:

code/index.ios.js

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';
import {
  Container,
  Title,
  Header,
  Content,
} from 'native-base';
import MainContent from './main';

class AwesomeNativeBase extends Component {
  render() {
    return (
      <Container>
        <Header>
          <Title>My awesome app</Title>
        </Header>
        <Content>
          <MainContent />
        </Content>
      </Container>
    );
  }
}
AppRegistry.registerComponent('AwesomeNativeBase', () => AwesomeNativeBase);

code/main.js

import React from 'react';
import { Text } from 'react-native';

export default class MainContent extends React.Component {
  render() {
    return (
      <Text>Oh hello there!</Text>
    );
  }
}

So now if you notice, I have just the <Text> tags in my main.js and not the <Content> tags... Not too sure why this makes a huge difference but it's good to know!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!