2

I'm trying to make a custom Text component for React Native with a google font using styled-components. My code is:

const Text = styled.Text`
    @import url('https://fonts.googleapis.com/cssfamily=Work+Sans:400,500&display=swap');
    font-family: 'Work Sans', sans-serif;
    font-size: ${props => (props.fontSize ? props.fontSize : `16px`)};

`;

But I'm getting the error

Error: Failed to parse declaration "fontFamily: 'Work Sans', sans-serif

Why is this?

  • You have to [**link the font**](https://medium.com/react-native-training/react-native-custom-fonts-ccc9aacf9e5e) on the native side to support custom fonts. – John Ruddell Jul 16 '19 at 16:07

0 Answers0