How to use the react-native-web.StyleSheet.flatten function in react-native-web

To help you get started, we’ve selected a few react-native-web examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github liivevideo / react-native-web-webrtc / RTCView / index.js View on Github external
const {
            streamURL,
            autoPlay,
            muted,
            accessibilityLabel,
            accessible,
            children,
            defaultSource,
            onLayout,
            source,
            testID
        } = this.props;

        const displayRTCView = resolveAssetSource(!isLoaded ? defaultSource : source);
        const backgroundRTCView = displayRTCView ? `url("${displayRTCView}")` : null;
        let style = StyleSheet.flatten(this.props.style);

        const resizeMode = this.props.resizeMode || style.resizeMode || RTCViewResizeMode.cover;
        // remove 'resizeMode' style, as it is not supported by View (N.B. styles are frozen in dev)
        style = process.env.NODE_ENV !== 'production' ? { ...style } : style;
        delete style.resizeMode;

        /**
         * RTCView is a non-stretching View. The rtcVideoView is displayed as a background
         * rtcVideoView to support `resizeMode`. The HTML rtcVideoView is hidden but used to
         * provide the correct responsive rtcVideoView dimensions, and to support the
         * rtcVideoView context menu. Child content is rendered into an element absolutely
         * positioned over the rtcVideoView.
         */
        var attributes = {src: streamURL}
        if (muted != null && muted != undefined && muted)
            attributes.muted = 'muted'
github newsuk / times-components / packages / jest-serializer / src / jest-serializer.js View on Github external
function transform(node) {
  if (!node || !node.props) return node;

  const { className, style: styles, ...props } = node.props;

  const children = (node.children || node.props.children || []).map(transform);

  const flattened = StyleSheet.flatten(styles);
  const style = Object.keys(flattened || {}).length ? { style: flattened } : {};

  return React.cloneElement(
    withoutProps(node),
    omitBy(
      {
        ...cleanSvgProps(node, props),
        ...transformRenderProps(props, transform),
        ...cleanClassNames(className),
        ...style
      },
      excludeProps
    ),
    ...children
  );
}
github newsuk / times-components / packages / jest-serializer / src / flatten-style.js View on Github external
export const flattenStyleTransform = (accum, node, props, children) => {
  const { style: styles, ...other } = props;
  const flattened = StyleSheet.flatten(styles);
  const style = Object.keys(flattened || {}).length ? { style: flattened } : {};

  return {
    accum,
    children,
    node,
    props: {
      ...other,
      ...style
    }
  };
};