How to use the aphrodite/lib/util.hashObject function in aphrodite

To help you get started, we’ve selected a few aphrodite 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 airbnb / react-with-styles-interface-aphrodite / src / utils / resolveWithRTL.js View on Github external
if (hasInlineStyles) {
    const inlineRTLStyles = generateDirectionalStyles(inlineStyles);

    if (inlineRTLStyles) {
      // Because we know nothing about the current directional context, there
      // is no way to determine whether or not the inline styles should be
      // flipped. As a result, if there are inline styles to be flipped, we
      // do so by converting them to classnames and providing styles in both
      // an RTL and an LTR context.
      // This may not work for all situations! For instance, when using inline
      // styles to animate a component with react-motion or animated.js,
      // converting to classes is likely to be way too slow. For those and
      // other edge-cases, consumers should rely on the resolveNoRTL method
      // instead.
      aphroditeStyles.push({
        _name: `inlineStyles_${hashObject(inlineRTLStyles)}`,
        _definition: inlineRTLStyles,
      });
    } else {
      result.style = inlineStyles;
    }
  }

  if (aphroditeStyles.length > 0) {
    result.className = css(...aphroditeStyles);
  }

  return result;
}
github styled-components / styled-components / src / models / Root.js View on Github external
injectStyles(): string {
    const { rules, fragments } = this.ruleSet.flatten()
    const className = `_${hashObject({ rules, fragments })}`
    injectCss(`.${className}`, rules, fragments)
    return className
  }
}