I\'m reading the React Native docs / tutorial, and I\'m wondering what the point of the StyleSheet.create function is.
For example, the tutorial has the
Here is there source code of create.
create(obj: T): {[key:$Keys]: number} {
var result: T = (({}: any): T);
for (var key in obj) {
StyleSheetValidation.validateStyle(key, obj);
result[key] = ReactNativePropRegistry.register(obj[key]);
}
return result;
}
I am not an expert of React in any. I actually never used it but here are my insights. It seems that create does some kind of validation over your keys and register them to React.
I think you could skip the validation by simply not calling create but I'm not sure what ReactNativePropRegistry.register does exactly.
Reference to the source