Search code examples
reasonreason-react

How to send actions between components?


The documentation explains how to send an action to self however I can't find how to send an action to another component. Right now I'm putting all of my app in a single big reducerComponent but I'd really like to be able to have a menu component with some buttons and an other component for the main game area and have the buttons change the state of the main game area.


Solution

  • It's very similar to React and well described in Thinking in React as

    React is all about one-way data flow down the component hierarchy. It may not be immediately clear which component should own what state. This is often the most challenging part for newcomers to understand...

    You should pass both handler and the state down to children from parent components. Good example can be found here.