meiosis-setup Documentation

Patches ⬆ Contents View Library

Initial State

When calling meiosisSetup, you can specify an app, with the following properties, all of which are optional:

We will look at each of these separately, starting with initial.

By default, the initial state is an empty object, {}. To specify a different initial state, use the initial property of app.

With TypeScript, app is of type MeiosisComponent, which we can import from 'meiosis-setup/types'. By indicating our State type, our app's initial state will be validated.

import { meiosisSetup } from 'meiosis-setup';
import { MeiosisComponent } from 'meiosis-setup/types';

interface State {
  name: string;
  age: number;
}

const app: MeiosisComponent<State> = {
  initial: {
    age: 25
  }
};

const cells = meiosisSetup<State>({ app });

By specifying the MeiosisComponent type on our app object, it will be validated and we can also benefit from auto-suggest on the properties (initial, services, etc.)

In the example below, try the following in the initial object, which should result in an error:

Patches ⬆ Contents View Library

Meiosis is developed by foxdonut (Twitter / GitHub) and is released under the MIT license.