How to use the inferno.options.reactStyles function in inferno

To help you get started, we’ve selected a few inferno 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 infernojs / inferno / packages / inferno-compat / src / index.ts View on Github external
function normalizeGenericProps(props) {
  for (const prop in props) {
    const mappedProp = InfernoCompatPropertyMap[prop];
    if (mappedProp && props[prop] && mappedProp !== prop) {
      props[mappedProp] = props[prop];
      props[prop] = void 0;
    }

    if (options.reactStyles && prop === 'style') {
      const styles = props.style;

      if (styles && !isString(styles)) {
        const newStyles = {};
        for (const s in styles) {
          const value = styles[s];
          const hyphenStr = hyphenCase(s);

          newStyles[hyphenStr] = isNumber(value) ? getNumberStyleValue(hyphenStr, value) : value;
        }
        props.style = newStyles;
      }
    }
  }
}
github infernojs / inferno / packages / inferno-compat / src / index.ts View on Github external
import {createElement} from 'inferno-create-element';
import {isArray, isFunction, isInvalid, isNull, isNullOrUndef, isNumber, isString, warning} from 'inferno-shared';
import {VNodeFlags} from 'inferno-vnode-flags';
import {isValidElement} from './isValidElement';
import PropTypes from './PropTypes';
import {InfernoCompatPropertyMap} from './InfernoCompatPropertyMap';
import {findDOMNode} from 'inferno-extras';
import {getNumberStyleValue, hyphenCase} from './reactstyles';

declare global {
  interface Event {
    persist: Function;
  }
}

options.reactStyles = true;

function unmountComponentAtNode(container: Element | SVGAElement | DocumentFragment): boolean {
  __render(null, container, null, null);
  return true;
}

export type IterateChildrenFn = (value: InfernoNode | any, index: number, array: Array) => any;

function flatten(arr, result) {
  for (let i = 0, len = arr.length; i < len; ++i) {
    const value = arr[i];
    if (isArray(value)) {
      flatten(value, result);
    } else {
      result.push(value);
    }