Open AdamGerthel opened 4 years ago
I'm using the following solution at the entry file for my project in order to set a default font:
import { Text } from 'react-native' Text.defaultProps = Text.defaultProps || {} Text.defaultProps.style = { fontFamily: 'Some fontname here' }
It's a neat and well-known solution to avoid having to specify a font on each text component (or having to write your own wrapper component for it).
But, for some reason, this doesn't work when using the MarkdownView component. I'm trying to specify fonts for bold and italic like this:
MarkdownView
<MarkdownView style={{ em: { fontFamily: 'Some italic font' }, strong: { fontFamily: 'Some bold font' } }}> Text goes here </MarkdownView>
But that doesn't seem to be working if I use the defaultProps solution. It seems the defaultProps are overriding the markdown-style. Removing that one line specifying the default font fixes it (but I'd like to be able to use that solution).
defaultProps
Is there a way to fix this?
I think you want to use "styles", not "style", property under MarkdownView
I'm using the following solution at the entry file for my project in order to set a default font:
It's a neat and well-known solution to avoid having to specify a font on each text component (or having to write your own wrapper component for it).
But, for some reason, this doesn't work when using the
MarkdownView
component. I'm trying to specify fonts for bold and italic like this:But that doesn't seem to be working if I use the
defaultProps
solution. It seems the defaultProps are overriding the markdown-style. Removing that one line specifying the default font fixes it (but I'd like to be able to use that solution).Is there a way to fix this?