menu
Menu
Mobify DevCenter
search_icon_focus

App Config

progressive-web-sdk/dist/ssr/universal/components/_app-config
class

AppConfig

This is a special component that can be overridden in a project. It supports two things:

1) Working with state management libraries such as Redux that need to set up <Provider> instances at the root of an application.

2) Injecting properties (such as Redux stores, API clients) into getProps() methods across an application. We can’t use React’s context to do this because getProps() and co. need to be static methods.

Import
import AppConfig from 'progressive-web-sdk/dist/ssr/universal/components/_app-config

Methods

render()

This class is a React Component in order to provide this hook, which lets you set up context Providers for a state-management library such as Redux.


restore(locals, frozen)

Restore a state management backend from frozen state that was embedded into the page HTML.

You can also use this to initialize a state-management library, and should save the instance onto locals.

ParameterDescription
localsres.locals on the server, an empty object as a substitute on the client.
frozenthe application state, restored from JSON in the HTML.

freeze(locals)

Freeze a state management backend for embedding into the page HTML.

Returns:

Object - - the application state as an object, which will be serialized into JSON and embedded in the page HTML.

ParameterDescription
localsres.locals on the server, an empty object as a substitute on the client.

extraGetPropsArgs(locals)

Return any extra arguments to be injected into getProps methods across the entire app, such as a Redux store.

Returns:

Object

ParameterDescription
localsres.locals on the server, an empty object as a substitute on the client.