Toni Joe
Toni Joe

Reputation: 8407

React Native: can't find variable: StyleSheet

I'm trying to style a Text element but I'm getting the following error:

Can't find variable: StyleSheet

This is the code:

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

const Header = () => (
    <Text style = {styles.textStyle}>This is the header</Text>
);

const styles = StyleSheet.create({
   textStyle: {
      fontSize: 20
  }
});
export default Header;

I can figure out what the problem is, did I miss something?

Upvotes: 1

Views: 2599

Answers (1)

Sricharan Kambhammettu
Sricharan Kambhammettu

Reputation: 308

import StyleSheet before using it.

import { StyleSheet, Text } from 'react-native';

Upvotes: 5

Related Questions