rn-css 1.6.6 → 1.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,12 +30,7 @@ const styled = (Component) => {
30
30
  // Build the css string with the context
31
31
  const css = react_1.default.useMemo(() => buildCSSString(chunks, functs, props, shared), [props, shared]);
32
32
  // Store the style in RN format
33
- const [rnStyle, setRNStyle] = react_1.default.useState(() => (0, cssToRN_1.default)(css));
34
- react_1.default.useEffect(() => {
35
- // Try to load an existing style from the style map or save it for next time
36
- const style = (0, cssToRN_1.default)(css);
37
- setRNStyle(style);
38
- }, [css]);
33
+ const rnStyle = react_1.default.useMemo(() => (0, cssToRN_1.default)(css), [css]);
39
34
  const { needsLayout, needsHover } = react_1.default.useMemo(() => ({
40
35
  // needsFontSize: !!css.match(/\b(\d+)(\.\d+)?em\b/)
41
36
  // needsScreenSize: !!cssString.current.match(/\b(\d+)(\.\d+)?v([hw]|min|max)\b/) || !!rnStyle.media,
@@ -83,10 +78,10 @@ const styled = (Component) => {
83
78
  }, [em, mediaQuery, tempStyle]);
84
79
  const units = react_1.default.useMemo(() => ({ ...baseUnits, em }), [baseUnits, em]);
85
80
  const styleConvertedFromCSS = react_1.default.useMemo(() => (0, convertStyle_1.default)(finalStyle, units), [finalStyle, units]);
86
- const style = react_1.default.useMemo(() => react_native_1.StyleSheet.flatten([styleConvertedFromCSS, props.style]), [props.style, styleConvertedFromCSS]);
81
+ const style = react_1.default.useMemo(() => [styleConvertedFromCSS, props.style], [props.style, styleConvertedFromCSS]);
87
82
  const newProps = react_1.default.useMemo(() => {
88
83
  const newProps = { style, onMouseEnter, onMouseLeave, onLayout };
89
- if (style.textOverflow === 'ellipsis')
84
+ if (react_native_1.StyleSheet.flatten(style).textOverflow === 'ellipsis')
90
85
  Object.assign(newProps, { numberOfLines: 1 });
91
86
  return newProps;
92
87
  }, [onLayout, onMouseEnter, onMouseLeave, style]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-css",
3
- "version": "1.6.6",
3
+ "version": "1.6.7",
4
4
  "scripts": {
5
5
  "test": "jest",
6
6
  "prepare": "tsc",
@@ -37,12 +37,7 @@ const styled = <Props, >(Component: React.ComponentType<Props>) => {
37
37
  // Build the css string with the context
38
38
  const css = React.useMemo(() => buildCSSString(chunks, functs, props, shared), [props, shared])
39
39
  // Store the style in RN format
40
- const [rnStyle, setRNStyle] = React.useState<Style>(() => cssToStyle(css))
41
- React.useEffect(() => {
42
- // Try to load an existing style from the style map or save it for next time
43
- const style = cssToStyle(css)
44
- setRNStyle(style)
45
- }, [css])
40
+ const rnStyle = React.useMemo(() => cssToStyle(css), [css])
46
41
 
47
42
  const { needsLayout, needsHover } = React.useMemo(() => ({
48
43
  // needsFontSize: !!css.match(/\b(\d+)(\.\d+)?em\b/)
@@ -95,10 +90,10 @@ const styled = <Props, >(Component: React.ComponentType<Props>) => {
95
90
  const units = React.useMemo<Units>(() => ({ ...baseUnits, em }), [baseUnits, em])
96
91
 
97
92
  const styleConvertedFromCSS = React.useMemo(() => convertStyle(finalStyle, units), [finalStyle, units])
98
- const style: StyleProp<any> = React.useMemo(() => StyleSheet.flatten([styleConvertedFromCSS, props.style]), [props.style, styleConvertedFromCSS])
93
+ const style: StyleProp<any> = React.useMemo(() => [styleConvertedFromCSS, props.style], [props.style, styleConvertedFromCSS])
99
94
  const newProps = React.useMemo(() => {
100
95
  const newProps: OptionalProps = { style, onMouseEnter, onMouseLeave, onLayout }
101
- if (style.textOverflow === 'ellipsis') Object.assign(newProps, { numberOfLines: 1 })
96
+ if (StyleSheet.flatten(style).textOverflow === 'ellipsis') Object.assign(newProps, { numberOfLines: 1 })
102
97
  return newProps
103
98
  }, [onLayout, onMouseEnter, onMouseLeave, style])
104
99