@@ -2,10 +2,8 @@ import PropTypes from 'prop-types';
22import React from 'react' ;
33import ReactDOM from 'react-dom' ;
44import BrowserProtocol from 'farce/BrowserProtocol' ;
5- import createInitialFarceRouter from 'found/createInitialFarceRouter' ;
6- import createFarceStore from 'found/createFarceStore' ;
5+ import createFarceRouter from 'found/createFarceRouter' ;
76import makeRouteConfig from 'found/makeRouteConfig' ;
8- import getStoreRenderArgs from 'found/getStoreRenderArgs' ;
97import { Resolver } from 'found-relay' ;
108import provideContext from 'fluxible-addons-react/provideContext' ;
119import debug from 'debug' ;
@@ -16,7 +14,6 @@ import {
1614 errorMiddleware ,
1715 cacheMiddleware ,
1816} from 'react-relay-network-modern' ;
19- import RelayClientSSR from 'react-relay-network-modern-ssr/lib/client' ;
2017import OfflinePlugin from 'offline-plugin/runtime' ;
2118import { Helmet } from 'react-helmet' ;
2219import { Environment , RecordSource , Store } from 'relay-runtime' ;
@@ -33,7 +30,6 @@ import ErrorBoundary from './component/ErrorBoundary';
3330import oldParamParser from './util/oldParamParser' ;
3431import { ClientProvider as ClientBreakpointProvider } from './util/withBreakpoint' ;
3532import meta from './meta' ;
36- import { isIOSApp } from './util/browser' ;
3733import {
3834 initAnalyticsClientSide ,
3935 addAnalyticsEvent ,
@@ -49,9 +45,9 @@ import {
4945
5046window . debug = debug ; // Allow _debug.enable('*') in browser console
5147
52- // TODO: this is an ugly hack, but required due to cyclical processing in app
53- const { config } = window . state . context . plugins [ 'extra-context-plugin' ] ;
48+ const { config } = window ;
5449const app = appCreator ( config ) ;
50+ const context = app . createContext ( { config } ) ;
5551
5652const getParams = query => {
5753 if ( ! query ) {
@@ -86,8 +82,6 @@ async function init() {
8682 await Promise . all ( modules ) ;
8783 }
8884
89- const context = await app . rehydrate ( window . state ) ;
90-
9185 // Get additional feedIds and searchParams from localstorage
9286 if ( config . mainMenu . countrySelection ) {
9387 const selectedCountries = context . getStore ( 'CountryStore' ) . getCountries ( ) ;
@@ -117,11 +111,6 @@ async function init() {
117111 }
118112 }
119113
120- // eslint-disable-next-line no-underscore-dangle
121- const relaySSRMiddleware = new RelayClientSSR ( window . __RELAY_PAYLOADS__ ) ;
122-
123- relaySSRMiddleware . debug = false ;
124-
125114 // Query parameter is used instead of header because browsers send
126115 // OPTIONS queries where you can't define headers
127116 const queryParameters = config . hasAPISubscriptionQueryParameter
@@ -134,7 +123,6 @@ async function init() {
134123 . getLanguage ( ) ;
135124
136125 const network = new RelayNetworkLayer ( [
137- relaySSRMiddleware . getMiddleware ( ) ,
138126 cacheMiddleware ( {
139127 size : 200 ,
140128 ttl : 60 * 60 * 1000 ,
@@ -159,8 +147,6 @@ async function init() {
159147 store : new Store ( new RecordSource ( ) ) ,
160148 } ) ;
161149
162- environment . relaySSRMiddleware = relaySSRMiddleware ;
163-
164150 setRelayEnvironment ( environment ) ;
165151
166152 const resolver = new Resolver ( environment ) ;
@@ -169,18 +155,7 @@ async function init() {
169155
170156 const historyProtocol = new BrowserProtocol ( ) ;
171157
172- const store = createFarceStore ( {
173- historyProtocol,
174- historyMiddlewares,
175- routeConfig,
176- } ) ;
177-
178- await getStoreRenderArgs ( {
179- store,
180- resolver,
181- } ) ;
182-
183- const Router = await createInitialFarceRouter ( {
158+ const Router = await createFarceRouter ( {
184159 historyProtocol,
185160 historyMiddlewares,
186161 routeConfig,
@@ -237,17 +212,8 @@ async function init() {
237212 headers : PropTypes . objectOf ( PropTypes . string ) ,
238213 } ) ;
239214
240- const root = document . getElementById ( 'app' ) ;
241- const { initialBreakpoint } = root . dataset ;
242-
243- // KLUDGE: SSR and CSR mismatch breaks the UI in iOS PWA mode
244- // see: https://github.com/facebook/react/issues/11336
245- if ( isIOSApp ) {
246- root . innerHTML = '' ;
247- }
248-
249215 const content = (
250- < ClientBreakpointProvider serverGuessedBreakpoint = { initialBreakpoint } >
216+ < ClientBreakpointProvider >
251217 < ContextProvider
252218 translations = { translations }
253219 context = { context . getComponentContext ( ) }
@@ -271,8 +237,8 @@ async function init() {
271237 </ ClientBreakpointProvider >
272238 ) ;
273239
274- ReactDOM . hydrate ( content , root , ( ) => {
275- // Run only in production mode and when built in a docker container
240+ const rootNode = document . getElementById ( 'app' ) ;
241+ ReactDOM . render ( content , rootNode , ( ) => {
276242 if ( process . env . NODE_ENV === 'production' && BUILD_TIME !== 'unset' ) {
277243 OfflinePlugin . install ( {
278244 onUpdateReady : ( ) => OfflinePlugin . applyUpdate ( ) ,
0 commit comments