Replies: 7 comments
-
I'm one of the cli-user and my only wish is that RNE stays smooth for us 👍 |
Beta Was this translation helpful? Give feedback.
-
Hey @piu130 could you let me know if something like this would affect RNW and how? |
Beta Was this translation helpful? Give feedback.
-
@iRoachie What exactly do you mean by affect? Here some thoughts: I don't know how to get expo working with RNW (Switched to cli long ago, maybe with For cli-user it depends on the used loader. You can load fonts inline, which would increase the bundle size, because you load all fonts, or async, which would load them when specific font-family is needed. I think it depends on the implementation of the Font Provider, the bundler and its font-loader but since it only affects expo users, RNW should also not be affected. Currently, RNW users must load the fonts manually like: const getFontTag = (fontName) => {
const style = document.createElement('style')
const fontUrl = require(`react-native-vector-icons/Fonts/${fontName}.ttf`)
const fontStyles = `@font-face {
src: url(${fontUrl});
font-family: '${fontName}';
}`
style.type = 'text/css'
style.appendChild(document.createTextNode(fontStyles))
return style
}
// loads font async, because the url refers a file
document.head.appendChild(getFontTag('MaterialIcons')) |
Beta Was this translation helpful? Give feedback.
-
agree!
I don't think it should load all the fonts, dunno how much fonts are you talking about but its better not to overload the users bundle for no reason.
maybe make sure the user understand that this component is useful in the Expo environment.
yes if we just let the user to choose from a set of options. maybe the most general ones like fade out, slide out... some questions:
|
Beta Was this translation helpful? Give feedback.
-
Also we have one more use case that we should tackle with this. Right now out get-icon-type helper includes all icons from react native vector icons(rnvi). That means that when new versions come out that include new icon sets, we force users to update to that version even if they’re not using the icons. |
Beta Was this translation helpful? Give feedback.
-
@iRoachie ok yes, maybe its a good idea to centralize all this imports in this new Provider. is there a way to dynamically load just the vectorIcons the user wants to load? If we still need to import all the icons I don't think this will help not importing them all :S The idea of having a common provider seems to me a good option now, but I think it will turn into the "provider for everything" and will over-complicate things. hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Yes! I think that should be the objective, only load the fonts the user needs. Maybe we should load |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Motivation
Right now for those using Expo, they have to manually add the fonts required for React Native Elements using Expo's Font.loadAsync. Without doing this, the app will crash with a red screen seen in #1005. This is pretty bad DX(developer experience) especially for newcomers who would have no idea how to implement this without searching through issues.
Proposed Solution
In v1.0.0-beta7 we introduced the
ThemeProvider
, which was a top-level component that surrounds your entire app. I think this is the perfect place to set up and load the fonts required by React Native Elements and maybe even allow users to register their own custom fonts as well. With that, we could probably rename it to ElementsProvider since it would now do more than just theming.Possible API
API subject to change:
Possible discussion
Beta Was this translation helpful? Give feedback.
All reactions