【问题标题】:Cannot override default Amplify withAuthenticator style with custom theme无法使用自定义主题覆盖默认的 Amplify withAuthenticator 样式
【发布时间】:2018-11-18 13:38:41
【问题描述】:

我正在尝试在我的 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',
  },
});

谁能指出我做错了什么?

【问题讨论】:

  • 你有没有想过这个问题?

标签: react-native aws-amplify


【解决方案1】:

您需要像这样传递 withAuthenticator 调用:

export default withAuthenticator(App, {includeGreetings: true, theme: MyTheme});

然后就可以了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-20
    • 1970-01-01
    • 2012-02-04
    • 2021-09-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多