Global style removed if another style is applied
Closed this issue · 2 comments
I tried using this to change the font globally in my project which is built using typescript,
However it seems like my text aren't inheriting the fontFamily that i specified
so in my App.tsx I initialized with loading the text and used the text inside setCustomText.
useEffect(() => {
Font.loadAsync({
Montserrat: require("./assets/font/Montserrat-Medium.otf")
});
setCustomText(styles.text);
}, []);
const styles = StyleSheet.create({
text: {
fontFamily: "Montserrat"
}
});
am I doing it wrong?
Can someone advise on how I can tackle this issue?
const firstRender = React.useRef(true);
useEffect(() => {
if (firstRender.current) {
firstRender.current = false;
Font.loadAsync({
Montserrat: require("./assets/font/Montserrat-Medium.otf")
});
const customTextProps = {
style: {
fontFamily: "Montserrat"
}
};
setCustomText(customTextProps);
}
}, []);
My apologies, I wasnt following directly as shown in the example.
Now it works, just that if I ever put a style on the Text, it will override this prop even though there is no fontFamily prop on the Text
It seems like it wasnt an issue from this library.
The replaced fonts are the fonts that is bold and react native cant just increase the weight of the fontFamily.
I needed to manually set another font for bold.
Closing this issue