How to use the react-native-web.AppRegistry.registerComponent function in react-native-web

To help you get started, we’ve selected a few react-native-web 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 AvenCloud / aven-legacy / src / ServerApp.js View on Github external
async function respondWithApp(
  App,
  props,
  res,
  path,
  docID,
  clientAgent,
  clientScriptID,
) {
  res.set("content-type", "text/html");
  // Horrible horrible horrible hacks to support react native web styles:
  const appKey = `App-${docID}-${path}`;
  const appKeys = AppRegistry.getAppKeys();
  if (appKeys.indexOf(appKey) === -1) {
    AppRegistry.registerComponent(appKey, () => App);
  }
  const { element, getStyleElement } = AppRegistry.getApplication(appKey, {
    initialProps: props,
  });
  const appHtml = ReactDOMServer.renderToString(element);
  const css = ReactDOMServer.renderToStaticMarkup(getStyleElement());

  const title = App.title;
  const html = `






<title>${title}</title>
github kiwicom / margarita / apps / web / pages / _document.js View on Github external
static getInitialProps({ renderPage }: (cb: Function) =&gt; void) {
    AppRegistry.registerComponent('Main', () =&gt; Main);
    // $FlowFixMe Wrong libdef. https://gist.github.com/paularmstrong/f60b40d16fc83e1e8e532d483336f9bb
    const { getStyleElement } = AppRegistry.getApplication('Main');
    const page = renderPage();

    const styles = [
      // eslint-disable-next-line react/jsx-key
      <style>,
      getStyleElement(),
    ];
    return { ...page, styles: React.Children.toArray(styles) };
  }
</style>
github threepointone / freezus / try / flip.js View on Github external
);
  }
}

function sleep(n: number) {
  return new Promise(resolve =&gt; setTimeout(resolve, n));
}

class Display extends React.Component&lt;{}, { screen: number }&gt; {
  state = { screen: 0 };
  render() {
    return  } /&gt;;
  }
}

AppRegistry.registerComponent('App', () =&gt; Display);

AppRegistry.runApplication('App', {
  initialProps: {},
  rootTag: window.root,
});

// A &lt;-&gt; B &lt;-&gt; C
//
//  content
//     set to position A'
//     put that inside another
github MainframeHQ / onyx / src / index.js View on Github external
// @flow

import { AppRegistry } from 'react-native-web'

import './index.css'
import Onyx from './Onyx'

document.addEventListener('dragover', event => event.preventDefault())
document.addEventListener('drop', event => event.preventDefault())

AppRegistry.registerComponent('Onyx', () => Onyx)
AppRegistry.runApplication('Onyx', {
  rootTag: document.getElementById('root'),
})
github newsuk / times-components / packages / ssr / src / lib / run-server.js View on Github external
getDataFromTree(app).then(() => {
    AppRegistry.registerComponent("App", () => () => app);

    const { element, getStyleElement } = AppRegistry.getApplication("App");
    const serverStylesheet = new ServerStyleSheet();

    const markup = ReactDOMServer.renderToString(
      serverStylesheet.collectStyles(element)
    );

    const responsiveStyles = serverStylesheet.getStyleTags();
    const styles = ReactDOMServer.renderToStaticMarkup(getStyleElement());

    const { helmet } = helmetContext;
    const headMarkup = helmet
      ? ["title", "meta", "link", "script"].reduce(
          (head, key) => head + helmet[key].toString(),
          ""
github pavjacko / renative / src / pages / _document.js View on Github external
static async getInitialProps({ renderPage }) {
        AppRegistry.registerComponent('Main', () =&gt; Main);
        const { getStyleElement } = AppRegistry.getApplication('Main');
        const page = renderPage();
        const styles = [
            <style>,
            getStyleElement()
        ];
        return { ...page, styles: React.Children.toArray(styles) };
    }
</style>
github reframejs / goldpage / plugins / react-native-web / domRender.js View on Github external
async function domRender({page, initialProps, CONTAINER_ID}) {
  const viewElement = React.createElement(page.view, initialProps);
  AppRegistry.registerComponent('App', () => () => viewElement);

  AppRegistry.runApplication('App', {
    initialProps,
    rootTag: document.getElementById(CONTAINER_ID),
  });
}
github codymurphyjones / NativeCore / packages / website / pages / _document.js View on Github external
static async getInitialProps({ renderPage }) {
    AppRegistry.registerComponent("Main", () =&gt; Main);
    const { getStyleElement } = AppRegistry.getApplication("Main");
    const page = renderPage();
    const styles = [
      <style>,
      getStyleElement()
    ];
    return {
      ...page,
      styles: React.Children.toArray(styles)
    };
  }
</style>
github RychardHunt / hodl-invest / app / src / App.js View on Github external
);
  }
}

AppRegistry.registerComponent('test', () =&gt; test);