App
<App/>
is the main component that bootstraps the Oneki.js framework on top of Create React App
This component is generally the external component of an application and is responsible for:
- creating a Redux store:
- If the
store
property is present, App doesn't create a Redux store but uses the one referenced by the property. - Otherwise, <App/> creates the Redux store. The initial state of the store is the object referenced by the property
initialState
.
- If the
- creating a React Router. By default, it creates a BrowserRouter that can be changed / configured via the settings.ts file
- creating and injecting global services in the Redux store
- creating a context that contains three elements:
- router: accessible via useRouter()
- settings: accessible via useSettings()
- redux store: accessible via useStore()
Custom redux store
A custom Redux store can be created by calling the helper createReduxStore
from Oneki.js
const store = createReduxStore((initialState = {}), (middlewares = []));
This helper expects an initial state and an array of Redux middlewares.
Properties
(Mandatory properties are in bold)Properties | Type | Description |
---|---|---|
settings | AppSettings | Promise<AppSettings> | Settings is a object usually defined in the file src/settings.ts Data defined in settings.ts is available throughout the application and contains configuration data. More info here |
Additional properties for advanced use cases
Properties | Type | Description |
---|---|---|
ErrorBoundaryComponent | ComponentType<ErrorBoundaryComponentProps> | The component displayed when an error occurs during the rendering phase Defaults to: no error boundary component |
i18nNs | string[] | More info here Defaults to: undefined |
initialLocale | string | Property to indicate the language to be used by default Defaults to: undefined |
initialState | AnyState | Promise<AnyState> | The initial state passed to the Redux store when it is created Defaults to: undefined |
LoadingComponent | ElementType | A component expected by <Suspense> (used to display a loading indicator)Defaults to: <DefaultLoadingComponent /> that displays "Loading..." |
services | Class<default<AnyState>>[] | A list of services that will be available globally in the application. More info here |
store | AppStore<any, AnyAction> | A standard Redux store, but created via the helper createReduxStore from onekijsThe store must be created via this helper so onekijs can control it Defaults to: A store created by <App/> (recommended) |
translations | AnonymousObject<AnonymousObject<string>> | An object containing the translations More info here Defaults to: undefined |