src/Native/NativeUi.js
/**
   * Converts a component node into an actual React Native node. Builds the
   * children array and props object, looks up the component by name on the
   * React Native module and calls into React.createElement.
   */
Converts a component node into an actual React Native node. Builds the
children array and props object, looks up the component by name on the
React Native module and calls into React.createElement.
Converts a component node into an actual React Native node . Builds the children array and props object looks up the component by name on the React Native module and calls into React . createElement .
function renderComponent(node, eventNode, key) {
    var children = [];
    for (var i = 0; i < node.children.length; i++) {
      children.push(renderTree(node.children[i], eventNode, i));
    }
    var finalProps = {};
    for (var j = 0; j < node.facts.length; j++) {
      var fact = node.facts[j];
      switch (fact.type) {
        case 'prop':
          finalProps[fact.propName] = fact.value;
          break;
        case 'ref':
          finalProps['ref'] = fact.callback;
          break;
        case 'renderProp':
          finalProps[fact.propName] = makeRenderNodePropHandler(fact, eventNode, key);
          break;
        case 'renderDecodedProp':
          finalProps[fact.propName] = makeRenderNodeDecodedPropHandler(fact, eventNode, key);
          break;
        case 'event':
          finalProps[fact.eventName] = makeEventHandler(eventNode, fact.decoder);
          break;
        case 'style':
          finalProps.style = fact.sheet;
          break;
      }
    }
    if(!finalProps.key) {
      finalProps.key = 'elm-native-ui-auto-added-' + key;
    }
    if (children.length === 1) {
      finalProps.children = children[0];
    } else if (children.length) {
      finalProps.children = children;
    }
    if (ReactNative[node.tagName]) {
      return React.createElement(ReactNative[node.tagName], finalProps);
    } else {
      if (!node.nativeComponent) {
          throw Error('Unable to find a node called ' + node.tagName + ' in ReactNative. Try defining it as a customNode');
      }
      return React.createElement(node.nativeComponent, finalProps);
    }
  }
function renderComponent ( node , eventNode , key ) { var children = [ ] ; for ( var i = 0 ; i < node . children . length ; i ++ ) { children . push ( renderTree ( node . children [ i ] , eventNode , i ) ) ; } var finalProps = { } ; for ( var j = 0 ; j < node . facts . length ; j ++ ) { var fact = node . facts [ j ] ; switch ( fact . type ) { case 'prop' : finalProps [ fact . propName ] = fact . value ; break ; case 'ref' : finalProps [ 'ref' ] = fact . callback ; break ; case 'renderProp' : finalProps [ fact . propName ] = makeRenderNodePropHandler ( fact , eventNode , key ) ; break ; case 'renderDecodedProp' : finalProps [ fact . propName ] = makeRenderNodeDecodedPropHandler ( fact , eventNode , key ) ; break ; case 'event' : finalProps [ fact . eventName ] = makeEventHandler ( eventNode , fact . decoder ) ; break ; case 'style' : finalProps . style = fact . sheet ; break ; } } if ( ! finalProps . key ) { finalProps . key = 'elm-native-ui-auto-added-' + key ; } if ( children . length === 1 ) { finalProps . children = children [ 0 ] ; } else if ( children . length ) { finalProps . children = children ; } if ( ReactNative [ node . tagName ] ) { return React . createElement ( ReactNative [ node . tagName ] , finalProps ) ; } else { if ( ! node . nativeComponent ) { throw Error ( 'Unable to find a node called ' + node . tagName + ' in ReactNative. Try defining it as a customNode' ) ; } return React . createElement ( node . nativeComponent , finalProps ) ; } }
Converts a component node into an actual React Native node.
Converts a component node into an actual React Native node .