Reactjs 将本机基本按钮与道具一起使用
我想创建一个可重用的按钮组件,但我有一些问题。我得到的Reactjs 将本机基本按钮与道具一起使用,reactjs,react-native,native-base,Reactjs,React Native,Native Base,我想创建一个可重用的按钮组件,但我有一些问题。我得到的未定义不是一个onject求值'\u nativebase.stylsheetcreate'。我试图破坏新闻和标题,但没有运气。有人能就如何解决这个问题给出一个明确的解释吗?谢谢 import React from 'react'; import { View, Text, Button, StyleSheet } from 'native-base'; export const StyledButton = props => {
未定义不是一个onject求值'\u nativebase.stylsheetcreate'
。我试图破坏新闻和标题,但没有运气。有人能就如何解决这个问题给出一个明确的解释吗?谢谢
import React from 'react';
import { View, Text, Button, StyleSheet } from 'native-base';
export const StyledButton = props => {
return (
<View style={styles.button}>
<Button
block
full
bordered
light
onPress={this.props.onPress}
>
<Text
style={{
color: '#FFFFFF',
}}
>
{this.props.title}
</Text>
{this.props.children}
</Button>
</View>
);
};
const styles = StyleSheet.create({
button: {
flex: 1,
padding: 10,
}
});
从“React”导入React;
从“原生基”导入{视图、文本、按钮、样式表};
export const StyledButton=props=>{
返回(
{this.props.title}
{this.props.children}
);
};
const styles=StyleSheet.create({
按钮:{
弹性:1,
填充:10,
}
});
渲染
<StyledButton
title='Cancel'
onPress={this.somefunction}
/>
删除
此
使用道具。someprop
import React from 'react';
import { StyleSheet } from 'react-native';
import { View, Text, Button } from 'native-base';
export const StyledButton = props => {
return (
<View style={styles.button}>
<Button block full bordered light onPress={props.onPress}>
<Text
style={{
color: '#FFFFFF',
}}>
{props.title}
</Text>
{props.children}
</Button>
</View>
);
};
const styles = StyleSheet.create({
button: {
flex: 1,
padding: 10,
}
});
从“React”导入React;
从“react native”导入{StyleSheet};
从“本机基”导入{视图、文本、按钮};
export const StyledButton=props=>{
返回(
{props.title}
{props.children}
);
};
const styles=StyleSheet.create({
按钮:{
弹性:1,
填充:10,
}
});
看起来native base没有提供样式表
如何将onpress传递给组件?我想在onPress={()=>{this.props.navigation.navigate('somepage');}上执行类似的操作。当我这样做的时候它不起作用,我没有使用这个功能。不能使用像onPress={()=>this.props.navigation.navigate('somescreen')}这样的导航道具吗?您需要将导航作为道具传递,并在您的on press中执行prop.navigation.navigate('Screen')
好的问题,onpress是否可能同时拥有导航道具和常规onpress道具?