Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { action } from 'mobx'
import { useObservable, useStaticRendering } from 'mobx-react-lite'
import { createContext, useCallback } from 'react'
const isServer = typeof window === 'undefined'
// eslint-disable-next-line react-hooks/rules-of-hooks
useStaticRendering(isServer)
let StoreContext = createContext()
let start
let stop
let store
function initializeData(initialData = store || {}) {
const { lastUpdate = Date.now(), light } = initialData
return {
lastUpdate,
light: Boolean(light),
}
}
function InjectStoreContext({ children, initialData }) {
let timerInterval = null
// Class for handling Webpack stats output
import Output from "@/lib/output";
// Every byte sent back to the client is React; this is our main template
import Html from "@/views/ssr";
// ----------------------------------------------------------------------------
// Types
export interface IRouterContext {
status?: number;
url?: string;
}
// Enable SSR-mode with MobX to avoid memory leaks
useStaticRendering(true);
// Everything from this point will be Webpack'd and dumped in `dist/server.js`
// and then loaded into an active Koa server
export default function(output: Output) {
// Create Koa middleware to handle React requests
return async (ctx: Context) => {
// Create a new Apollo client
const client = createClient();
// Create a fresh 'context' for React Router
const routerContext: IRouterContext = {};
// Render our components - passing down MobX state, a GraphQL client,
// and a router for rendering based on our route config
const components = (
import { Request, Response } from 'express-serve-static-core'
import { useStaticRendering } from 'mobx-react-lite'
import { types } from 'mobx-state-tree'
import { createContext, useContext } from 'react'
import { checkTokenIsExpired, removeMapInCookie, setMapInCookie } from '../helpers'
const isServer = typeof window === 'undefined'
useStaticRendering(isServer)
export interface IEnvironments {
[key: string]: string
}
export interface ITokens {
accessToken: string
refreshToken: string
}
export type IStore = typeof Store.Type
type IStoreState = typeof Store.CreationType
let store: IStore | null = null
export function createStore(storeState: IStoreState): IStore {
if (isServer) {