Open shirakaba opened 4 years ago
Funny I was looking at Styled Components and thought of a way I'd used them with RNS.
As for strongly-typed style objects (à la React Native's StyleSheet.create()
), this seems to do the trick:
import type { RNSStyle } from "react-nativescript";
type RNSStyleSheet<T extends {}> = {
[P in keyof T]: RNSStyle;
}
export const createStyleSheet = <T extends {}>(arg: RNSStyleSheet<T>): RNSStyleSheet<T> => arg;
RNS v2.2.0 now implements a provisional StyleSheet.create()
API.
Accepting an array of styles is not yet supported, but now that I've fixed a styles issue, it may be not far off being implemented.
Should accept an array of styles (like React Native), and should not throw an error if an
undefined
style is passed in (because we've marked it as optional).Should probably also be added to the typings of ViewBase so that it comes up in, e.g. FlexboxAttributes.