4

I am trying to customize the styling of the AWS WithAuthenticator HOC in my React Native application. I followed the Amplify documentation step by step. However, the app keeps rendering the default styling (orange buttons) instead of the expected custom color.

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',
  },
});

Can anyone point me to what am I doing wrong?

1
  • 4
    Did you ever figure this out? Commented Mar 16, 2019 at 6:40

1 Answer 1

0

You need to pass the withAuthenticator call like this:

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

Then it will work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.