question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid prop `buttonStyle` supplied to `Button`

See original GitHub issue

What I did

I’m currently on React Native version 0.63.3, React Native Web version 0.14.3, and React Native Elements version 3.0.0-alpha.1.

I get the below error in the console on a simple Button import and rendering. Looking at the TS declarations on Button, buttonStyle is clearly a valid prop from the extended ButtonProps interface in react-native-elements.

I think the issue is occurring due to React Native’s Button not having buttonStyle on its props.

export interface ButtonProps {
    title: string;
    onPress: (ev: NativeSyntheticEvent<NativeTouchEvent>) => void;
    color?: ColorValue;
    accessibilityLabel?: string;
    disabled?: boolean;

    /**
     * Used to locate this button in end-to-end tests.
     */
    testID?: string;
}

export class Button extends React.Component<ButtonProps> {}
import {
  KeyboardAvoidingView,
  Platform,
  StyleSheet,
  TextInput
} from 'react-native';
import { Button } from 'react-native-elements';

const styles = StyleSheet.create({
  fbLoginButton: {
    height: 45,
    marginTop: 10,
    backgroundColor: 'transparent'
  },
  loginButton: {
    borderRadius: 5,
    height: 45,
    marginTop: 10,
    backgroundColor: 'rgba(56, 151, 241, 1)'
  }
});

// Component code scaled down for simplicity
const MyComp = () => (
    <KeyboardAvoidingViewStyled
      behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
    >
      <LoginScreenContainer device={Platform.OS}>
        <LoginFormView>
          <Button buttonStyle={styles.loginButton} title="Login" />
        </LoginFormView>
      </LoginScreenContainer>
    </KeyboardAvoidingViewStyled>
  );
Warning: Failed prop type: Invalid prop `buttonStyle` supplied to `Button`.
    at Button (http://localhost:19006/static/js/bundle.js:65901:81)

Expected behavior (Required)

Render the component with Button and no errors.

To Reproduce (Required)

For some reason I can’t reproduce it on this Snack.

Any thoughts?

Screenshots (Required)

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
avgupta456commented, Dec 10, 2020

I also ran into this exact issue for buttonStyle, titleStyle, containerStyle and others. I was able to resolve my errors by wrapping my styles in an array, or moving the object from the stylesheet directly into the prop.

<Button buttonStyle={styles.loginButton} title="Login" /> // did not work
<Button buttonStyle={[styles.loginButton]} title="Login" /> // did work
<Button buttonStyle={{ borderRadius: 5, ... }} title="Login" /> // did work

Hope this helps someone else!

0reactions
cglacetcommented, May 10, 2021

We have this error on 3.2.0, wrapping in an array does solve the problem, but it looks ugly. We also have the same error in the containerStyle prop.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning: Failed prop type: Invalid prop `textStyle` of type ...
this is my code which going to create a table, it is working well but every time its showing me the (Warning: Failed...
Read more >
Common Props - Victory
These props may be set by passing them directly to the supplied component. ... <button onClick={this.clearClicks.bind(this)} style={buttonStyle}
Read more >
Using React Native Elements, a cross-platform UI toolkit
React Native Elements is a user interface kit that makes it easy to integrate customizable icons and labels into your project.
Read more >
react-dropzone
Simple React hook to create a HTML5-compliant drag'n'drop zone for files. Documentation and examples at https://react-dropzone.js.org.
Read more >
Components - NativeBase
NativeBase has provided its users with enormous list of props that can be used with ... Include bordered prop with Button to apply...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found