-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to disable font scaling of @react-native-picker/picker #564
Comments
Hi @ksquaresys22, I managed to prevent font scaling in the picker component by modifying a file in the library and patching it, below are the adjustments in the .patch file that I made:
If you have the version 8.1.0 you can easily copy and paste the previous code and create a file called: react-native-picker-select+8.1.0.patch inside a folder named patches in the root of your project. Afterwards run the following command:
Choosing one or another depends on your project. When the installation process has finished, add the following script inside the "scripts" property of your package json: "postinstall": "patch-package", The purpose of that script is to run after you install your project's dependencies and apply the patch to the library. If you want to do it by yourself without the patch file I left above, go to the following path: "your_project/node_modules/react-native-picker-select/src/index.js" and apply the changes using the calculateFixedFontSize function inside the style property of the <Picker.Item component returned by the renderPickerItems method:
With the changes made you can test by changing the default font size in your device's display settings and check how the font doesn't scale inside the picker. Don't forget to commit the changes made in order to preserve the patch inside your project. That's it, I hope this helps everyone facing the same challenge. patch-package: https://www.npmjs.com/package/patch-package |
If we want to disable font scaling, we can add this code to app.js or index.js.
We want to disable the font scaling of the picker component in the same way.
Please help me
The text was updated successfully, but these errors were encountered: