Skip to content

Instantly share code, notes, and snippets.

@tastycode
Last active April 20, 2018 16:55
Show Gist options
  • Save tastycode/f5e2a62b125b73537affcb9659ff386e to your computer and use it in GitHub Desktop.
Save tastycode/f5e2a62b125b73537affcb9659ff386e to your computer and use it in GitHub Desktop.
Dispatching without making an action creator
// types.js
const REPORTER_PENDING_REPORT_UPDATE = "[reporter] pending report update"
// components/PromptHarm.js
import types from 'types'
const PromptHarm = ({dispatch}) => ( <PromptContainer>
<PromptText>Is anyone at risk of immediate harm to themselves or others?</PromptText>
<PromptButtonsContainer>
<PromptButton onClick={() => dispatch({types: types.REPORTER_PENDING_REPORT_UPDATE})} text="YES"/>
<PromptButton text="CANCEL"/>
</PromptButtonsContainer>
</PromptContainer>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment