Invalid value for stylesheet property only fails at runtime

When using an invalid value for a stylesheet property, for example flex: "1" (the right type for the flex property is Number), everything succeeds, including the build, and then fails at runtime with an exception that prevents the application from working.

I was expecting that these errors would be caught at build time but it doesn’t seem to be the case. Any thoughts?

Yes, this is a bit annoying.

Fortunately it’s not something that has tripped me up often.

You could give this a try:

Makes no difference unfortunately. To clarify, I wouldn’t expect the bundler to be able to catch that, but when running the build in Expo, when the code is turned into native, I would definitely expect that these errors are caught.

It’s fairly easy to make mistakes when authoring stylesheets, especially when you come from Web and you’re used to the browser being a lot more forgiving, or supporting things that don’t exist in RN.

The fact that these errors can only be caught at runtime is definitely not great.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.