The problem
The return type of RNW StyleSheet.create is incompatible with RN StyleSheet.create. This causes problems in css libraries where RN is aliased to RNW via https://www.npmjs.com/package/babel-plugin-react-native-web.
RNW implementation:
|
create(styles: Object): {| [key: string]: number |} { |
|
const result = {}; |
|
Object.keys(styles).forEach((key) => { |
|
if (process.env.NODE_ENV !== 'production') { |
|
validate(key, styles); |
|
} |
|
const id = styles[key] && ReactNativePropRegistry.register(styles[key]); |
|
result[key] = id; |
|
}); |
|
return result; |
|
}, |
RN implementation:
https://github.com/facebook/react-native/blob/36318b6776507ba31070f6c8a3493609238a1a98/Libraries/StyleSheet/StyleSheet.js#L359-L371
How to reproduce
// RNW
StyleSheet.create({
foo: {
color: 'blue'
}
})
// results in: { foo: 89 }
// RN
StyleSheet.create({
foo: {
color: 'blue'
}
})
// results in: { foo: { color: 'blue' } }
Simplified test case: Not sure if this is useful: https://codesandbox.io/s/async-bush-kfpgo?file=/src/App.js
Expected behavior
I expect the return type to match RN.
Environment (include versions). Did this work in previous versions?
- React Native for Web (version): 0.17.0
- React (version): 16.14.0
- Browser: n/a
Additional context
The problem
The return type of RNW
StyleSheet.createis incompatible with RNStyleSheet.create. This causes problems in css libraries where RN is aliased to RNW via https://www.npmjs.com/package/babel-plugin-react-native-web.RNW implementation:
react-native-web/packages/react-native-web/src/exports/StyleSheet/StyleSheet.js
Lines 47 to 57 in 13f7b9e
RN implementation:
https://github.com/facebook/react-native/blob/36318b6776507ba31070f6c8a3493609238a1a98/Libraries/StyleSheet/StyleSheet.js#L359-L371
How to reproduce
Simplified test case: Not sure if this is useful: https://codesandbox.io/s/async-bush-kfpgo?file=/src/App.js
Expected behavior
I expect the return type to match RN.
Environment (include versions). Did this work in previous versions?
Additional context