From c45d7b282648ff66094ce6ff0186351ea6ca64d8 Mon Sep 17 00:00:00 2001 From: benji Date: Thu, 14 Dec 2017 15:24:05 +0100 Subject: [PATCH] Add information about transition function --- README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e46f0b8..b9638c3 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,11 @@ npm install fsm-hoc --save ## Usage This module provides a function to wrap your components in a finite state machine. +This gives your component to additional props: `status` and `transition`. + +The status is the current status of the component. +Transition is a function that takes as first argument `this`, and as second an object with +`type` key that contains the `Action`. ### Type arguments @@ -102,10 +107,20 @@ class Form extends React.Component, State> ... + onSubmit() { + this.props.transition(this, { type: Action.Submit }); + } + render() { return ( ... - Submit + + Submit + ... ); }