index.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { Actions, reducer, Selectors } from '@andyet/simplewebrtc';
  2. import React from 'react';
  3. import ReactDOM from 'react-dom';
  4. import { Provider } from 'react-redux';
  5. import {
  6. applyMiddleware,
  7. combineReducers,
  8. compose as ReduxCompose,
  9. createStore
  10. } from 'redux';
  11. import Thunk from 'redux-thunk';
  12. import App from './App';
  13. import './index.css';
  14. // ====================================================================
  15. // !! IMPORTANT SETUP !!
  16. // ====================================================================
  17. // Set this to the API key you received with your SimpleWebRTC account.
  18. // You can visit accounts.simplewebrtc.com to find your API key.
  19. // ====================================================================
  20. const API_KEY: string = '';
  21. const CONFIG_URL = `https://api.simplewebrtc.com/config/guest/${API_KEY}`;
  22. const compose =
  23. (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || ReduxCompose;
  24. const store = createStore(
  25. combineReducers({ simplewebrtc: reducer }),
  26. { simplewebrtc: {} },
  27. compose(applyMiddleware(Thunk))
  28. );
  29. // These are exposed to make it easier to inspect while debugging and
  30. // learning how SimpleWebRTC works.
  31. (window as any).store = store;
  32. (window as any).actions = Actions;
  33. (window as any).selectors = Selectors;
  34. if (!API_KEY) {
  35. ReactDOM.render(
  36. <div>
  37. <p>Edit src/index.tsx to set your API key.</p>
  38. <p>Visit <a href="https://simplewebrtc.com">simplewebrtc.com</a> to sign up and get an API key.</p>
  39. </div>,
  40. document.getElementById('root')
  41. );
  42. } else {
  43. ReactDOM.render(
  44. <Provider store={store}>
  45. <App configUrl={CONFIG_URL} />
  46. </Provider>,
  47. document.getElementById('root')
  48. );
  49. }