How to use styletron-legacy - 2 common examples

To help you get started, we’ve selected a few styletron-legacy 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 styletron / styletron / packages / demos / react-demo-compat / src / server.js View on Github external
function generateHydrationScriptSrc(keys) {
  var sanitizedKeys = safeString(JSON.stringify(keys));
  return [
    ';try{',
      '(function(){',
        'window["', StyletronLegacy.constants.HYDRATE_KEY, '"]=', sanitizedKeys, ';',
      '})();',
    '}catch(e){};',
  ].join('');
}
github styletron / styletron / packages / demo-fixtures / compat.js View on Github external
function CompatComponent(props, context) {
  if (context.styletron) {
    var styleName = context.styletron.injectDeclaration({prop: 'color', val: 'red'});
    return React.createElement('div',
      {className: styleName}, 'I am a compat component');
  } else {
    styletronLegacy.injectOnce('.compatStyle { color: red }', '__compat_style__');
    return React.createElement('div',
      {className: 'compatStyle'}, 'I am a compat component');
  }
}

styletron-legacy

Legacy package for 1.x styletron

MIT
Latest version published 6 years ago

Package Health Score

53 / 100
Full package analysis

Similar packages