自定义组件
import React, { Component } from 'react'
import { Text } from 'react-native'
import { Content } from 'native-base'
export default class Login extends Component {
render () {
return (
<Content>
<Text>This is stateless Component</Text>
</Content>
)
}
}
index.ios.js
import React, { Component } from 'react'
import { AppRegistry, Text, View } from 'react-native'
import { Container, Header, Title, Content } from 'native-base'
import Login from './src/components/Login'
export default class MyApp extends Component {
render () {
return (
<Container>
<Header>
<Title>Login</Title>
</Header>
<Login />
</Container>
)
}
}
AppRegistry.registerComponent('MyApp', () => MyApp)
仅在正在运行的应用中显示标题。预期This is stateless Component
不存在。请问任何人都可以看一下吗?
答案 0 :(得分:1)
您只能在容器组件中使用 native-base 的Content组件:
import React, { Component } from 'react'
import { Text } from 'react-native'
import { Container, Content } from 'native-base'
export default class Login extends Component {
render () {
return (
<Container>
<Content>
<Text>This is stateless Component</Text>
</Content>
</Container>
)
}
}