我正在尝试在我的React Native应用程序中自定义AWS WithAuthenticator HOC的样式。我一步一步地遵循了放大documentation。但是,该应用会继续呈现默认样式(橙色按钮),而不是预期的自定义颜色。
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Amplify from '@aws-amplify/core';
import config from './aws-exports';
import { withAuthenticator } from 'aws-amplify-react-native';
import { AmplifyTheme } from 'aws-amplify-react-native';
// custom colors for components
const Mybutton = Object.assign({}, AmplifyTheme.button, { backgroundColor: '#000', });
//console.log('My own design: ', Mybutton)
const MyTheme = Object.assign({}, AmplifyTheme, { button: Mybutton });
class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>You are now signed in!</Text>
</View>
);
}
}
export default withAuthenticator(App, { includeGreetings: true }, false, [], null, MyTheme)
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
有人能指出我在做什么吗?
答案 0 :(得分:0)
您需要像这样传递withAuthenticator调用:
export default withAuthenticator(App, {includeGreetings: true, theme: MyTheme});
然后它将起作用。