You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 30, 2020. It is now read-only.
A minimal-ish reproduction of the issue is set out below. I'm using purescript-redux with purescript-react. In short, the first reducer action (DECREMENT) is automatically dispatched, despite that no dispatch is made. In the example below, the initial state is 0, but it's immediately decremented.
moduleMainwhereimportPreludeimportControl.Monad.EffimportControl.Monad.Eff.ConsoleimportData.Maybe.Unsafe (fromJust)
importData.Nullable (toMaybe)
importDOM (DOM())
importDOM.HTML (window)
importDOM.HTML.Types (htmlDocumentToDocument)
importDOM.HTML.Window (document)
importDOM.Node.NonElementParentNode (getElementById)
importDOM.Node.Types (Element(), ElementId(..), documentToNonElementParentNode)
importReactimportReactDOM (render)
importReact.DOMasDimportReact.DOM.PropsasPimportControl.Monad.Eff.ReduxtypeAppState=Int
incrementA = "INCREMENT"
decrementA = "DECREMENT"mainReducer::forallab. AppState->Actionab->AppState
mainReducer state action =
case action.type of
decrementA -> state - 1
incrementA -> state + 1
_ -> state
home::forallprops. ReactClassStore
home = createClass $ spec unit $ \ctx ->do
store <- getProps ctx
state <- getState store
log $ ("The state is: " ++ (show (state ::Int)))
return $
D.h1 []
[ D.text "The state should be 0, but instead it's: "
, D.text (show (state ::Int))
]
main::foralleff. Eff (dom::DOM, reduxM::ReduxM | eff ) Unit
main = do
store <- createStore mainReducer (0)
let appRender = (elm' >>= render (ui store) >>= \_ -> return unit)
subscribe appRender store
appRender
whereui::Store->ReactElement
ui str = D.div' [ createFactory home str]
elm'::foralleff. Eff (dom::DOM | eff) Element
elm' = do
win <- window
doc <- document win
elm <- getElementById (ElementId"app") (documentToNonElementParentNode (htmlDocumentToDocument doc))
return $ fromJust (toMaybe elm)
The text was updated successfully, but these errors were encountered:
A minimal-ish reproduction of the issue is set out below. I'm using
purescript-redux
withpurescript-react
. In short, the first reducer action (DECREMENT
) is automatically dispatched, despite that no dispatch is made. In the example below, the initial state is 0, but it's immediately decremented.The text was updated successfully, but these errors were encountered: