React: how to pass component identity to Redux state
<p>Is it safe to pass <code>this</code> to Redux action creator from withing component defined using <code>React.createClass</code>?</p>

<p>I have defined the following reducer:</p>

<pre><code>const unsavedChangesProtectionReducer = handleActions({
    [ENABLE_UNSAVED_CHANGES_PROTECTION]: (unsavedChangesProtection, action) =&gt; ({protected: true}),
    [DISABLE_UNSAVED_CHANGES_PROTECTION]: (unsavedChangesProtection, action) =&gt; ({protected: false})},
    {protected: false}
)
</code></pre>

<p>Multiple components may set/unset the global <em>state.unsavedChangesProtection.protected</em> flag, and problem arises from unsetting this flag, as component shouldn't unset it if some other component has set it before this component.</p>

<p>One solution is to check if flag is already set and if not, set it, store the info about component setting the flag in component's internal state, and unset it if internal state states that component has set the flag. However, this violates the DRY principle, as I have to introduce exactly same login in every component.</p>

<p>More generalized solution would be to store the identity of the component which lastly mutated the global state as a member of state itself, so each component can see from the state if it's their change and unset in accordingly. Is this possible to implement in React, as each component are re-initialized when mounted/unmounted</p>