React-Actor
A simple data library of React. Use the action model.
This library is used to resolve the problem of the communication between react components, no matter if they are parent-son or not.
Install
npm install react-actor --save
Usage
- Define a component and register an action to listen
{ super...args thisstate = messages: tile: 'title1' time: 1234567989 tile: 'title2' time: 1234564999 // register a response function of an action this } { return <ul> thisstatemessages </ul> }
- Trigger the action with data
// trigger the action with data { this } { return <button onClick= thisaddMsg >add message</button> }
Docs
-
onAction
@param actionName { string } - the action name to listen@param callback Function - the response -
act
@param actionName { string } - the action name to trigger@param callback Function - the data to send with the action triggered