Back to API Reference.
initializeLaunch is a function that is used to initialize your React application with Launch.IO. It should be called before your application is first rendered.
services array
The array of application Services. Each service object will consist of name (string), initialState (object), and actions (object) properties.
options object
Contains the Launch.IO configuration properties:
-
enableTimeTravel(boolean) indicates whether or not time travel debugging is enabled. This has a default value offalseand it should not be enabled in non-development environments. -
timeTravelHistoryLimit(number) indicates how many time travel actions are stored in history. This has a default value of 50.
import React from "react";
import { initializeLaunch } from "launch.io";
const calculatorService = {
name: "calculator",
initialState: {
value: 0,
},
actions: {
increase: ({ state }, payload) => ({ value: state.value + payload }),
decrease: ({ state }, payload) => ({ value: state.value - payload }),
},
};
initializeLaunch([calculatorService], { enableTimeTravel: true });
const App = () => {
return <div className="MyApp">...</div>;
};
export default App;