Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Bug: In Using the theme in your own components #3309

Closed
avimishra18 opened this issue Jan 22, 2022 · 0 comments · Fixed by #3310
Closed

Documentation Bug: In Using the theme in your own components #3309

avimishra18 opened this issue Jan 22, 2022 · 0 comments · Fixed by #3310

Comments

@avimishra18
Copy link

Explain what you did

I was reading documentation and came across a possibly erroneous code snippet.

Steps

  1. Visit Using the theme in your own components
  2. Scroll to makeStyles() example

Code Snippet

I have written possible errors as comments.

import React from 'react';
import { Text } from 'react-native';
import { makeStyles } from 'react-native-elements';

// 1. All other examples are JS but this example as TS?
type Params = {
  fullWidth?: boolean,
};

const MyComponent = (props: Props) => {
  const styles = useStyles(props);

  return (
    {/*  2. 'View' & 'theme' are not defined. */}
    <View style={styles.container}>
      <Text style={{ color: theme.colors.primary }}>Yo!</Text>
    </View>
  );
};

const useStyles = makeStyles((theme, props: Props) => ({
  container: {
    background: theme.colors.white,
    width: props.fullWidth ? '100%' : 'auto',
  },
  text: {
    color: theme.colors.primary,
  },
}));

Possible Solution

Check Snack for the corrected as well as the original code.

Screenshot

Screenshot-2022-01-22-at-16-15-28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant