How to use the rax.render function in rax

To help you get started, we’ve selected a few rax 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 alibaba / rax / packages / rax-app / src / runApp.js View on Github external
InitialComponent: _initialComponent
      });

      if (shell) {
        const shellData = initialDataFromSSR ? initialDataFromSSR[SHELL_DATA] : null;
        appInstance = createElement(shell.component, { data: shellData }, appInstance);
      }

      // Emit app launch cycle.
      emit('launch');

      let rootEl = isWeex ? null : document.getElementById('root');
      if (isWeb && rootEl === null) throw new Error('Error: Can not find #root element, please check which exists in DOM.');

      // Async render.
      return render(
        appInstance,
        rootEl,
        { driver: UniversalDriver, hydrate }
      );
    })
    .catch((err) => {
github alibaba / rax-map / api / components / marker / index.js View on Github external
setChildComponent(props) {
    if (this.contentWrapper) {
      if ('className' in props && props.className) {
        // https://github.com/ElemeFE/react-amap/issues/40
        this.contentWrapper.className = props.className;
      }
      if ('render' in props) {
        renderMarkerComponent(props.render, this.marker);
      } else if ('children' in props) {
        const child = props.children;
        const childType = typeof child;
        if (childType !== 'undefined' && this.contentWrapper) {
          render(, this.contentWrapper);
        }
      }
    }
  }
github alibaba / rax / packages / rax-clone-element / src / __tests__ / cloneElement.js View on Github external
it('should transfer children', function() {
    class MyComponent {
      render() {
        expect(this.props.children).toBe('xyz');
        return <div>;
      }
    }

    render(
      cloneElement(, {children: 'xyz'})
    );
  });
</div>
github alibaba / rax / packages / rax-unmount-component-at-node / src / __tests__ / unmountComponentAtNode.js View on Github external
it('unmout component', () =&gt; {
    let appendChildMock = jest.fn();
    let removeChildMock = jest.fn();
    let body = {tagName: 'BODY'};

    Host.driver = {
      createElement() {
        return {tagName: 'DIV'};
      },
      appendChild: appendChildMock,
      removeChild: removeChildMock,
      removeAllEventListeners() {}
    };

    render(<div>, body);
    unmountComponentAtNode(body);

    let call = appendChildMock.mock.calls[0];
    expect(call[0].tagName).toBe('DIV');
    expect(call[1].tagName).toBe('BODY');

    let call2 = removeChildMock.mock.calls[0];
    expect(call2[0].tagName).toBe('DIV');
    expect(call2[1].tagName).toBe('BODY');
  });
});</div>
github alibaba / rax / packages / rax-app / src / runApp.web.js View on Github external
} else {
    history = createHashHistory();
  }

  let entry = createElement(Entry, { history, routes });

  if (shell) {
    entry = createElement(shell.component, { data: initialData.shellData }, entry);
  }

  if (!launched) {
    launched = true;
    emit('launch');
  }

  render(
    entry,
    document.getElementById('root'),
    { driver: UniversalDriver, hydrate }
  );
}
github alibaba / rax / examples / perf / index.js View on Github external
{childUpdate ?  : null}
    ;
  }
}

const styles = {
  title: {
    color: '#ff4400',
    fontSize: 48,
    fontWeight: 'bold',
  }
};

Perf.start();
render(, null, {
  measurer: Perf.Measurer
});
Perf.stop();

let measurements = Perf.getLastMeasurements();
Perf.printInclusive(measurements);
Perf.printExclusive(measurements);
github alibaba / rax / packages / rax-create-portal / src / index.js View on Github external
renderPortal() {
    render(this.props.element, this.props.container, {
      parent: this
    });
  }
github alibaba / rax / scripts / bench / frameworks / rax / src / main.jsx View on Github external
const Main = () =&gt; {
  const [state, dispatch] = useReducer(listReducer, { data: [], selected: 0 });

  return (<div>
    
    
      {state.data.map(item =&gt; (
        
      ))}
    <table><tbody></tbody></table>
    <span aria-hidden="true">
  </span></div>);
};

render(<main>, document.getElementById('main'), { driver: DriverDOM });</main>
github alibaba / rax / packages / rax-weex / src / index.js View on Github external
export function render(element, container, callback) {
  return originRender(element, container, {
    driver: WeexDriver
  }, callback);
}