Closed vreality64 closed 5 years ago
@vreality64 I think it was done to avoid accidental access to style props that do not exist. But actually i agree with you - it can give more problems than profit. Could you please check is RN original stylesheet has prototype chain or not? If it has - we should definitely be the same. Thank you!
@vitalets
As you can see, StyleSheet.create({ ... })
actually doesn't do anything on prototype. RN original stylesheet has prototype chain, because they return original object.
Here are code sandbox link.
@vreality64 Thank you for the research! Will fix it and release.
@vitalets
In my opinion, simplest and good solution is just changing sheet.getResult()
to Object.assign({}, sheet.getResult())
in code. It's already ES6 base. 😃
Steps to Reproduce
It's basic concept question. It could be bug or not based on situation. There is some console warning when use React Native's
FlatList
component with created style sheet.Expected Behavior
It shouldn't warn anything.
Actual Behavior
there are console warning in development mode
Show the code
This code makes console warning because
Object.create(null)
doesn't have prototype chain ofObject
. Is this intended?Environment
Suggestions
Object.create(null)
is internally okay as usage of map. However it has underlying possible error about Object prototype chain which is not easily noticed. I thinks it'd better to having prototype chain of Object in result ofcreate
function.