Skip to content

Instantly share code, notes, and snippets.

@persianturtle
Created February 13, 2018 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save persianturtle/5d710fc4b42197ed136148564d049f63 to your computer and use it in GitHub Desktop.
Save persianturtle/5d710fc4b42197ed136148564d049f63 to your computer and use it in GitHub Desktop.
Just the reducer field (solution 2)
[@bs.val] [@bs.scope "document"] external documentElement : Dom.element = "";
...
reducer: (action, state) =>
switch action {
| Navigate(_routeWithTitle) => ReasonReact.NoUpdate
| ToggleMenu(isOpen) =>
ReasonReact.UpdateWithSideEffects(
{
...state,
nav: {
isOpen: isOpen
}
},
(
_self =>
if (isOpen) {
/* [%bs.raw {| document.documentElement.style.overflow = "hidden"|}]; */
ReactDOMRe.domElementToObj(documentElement)##style##overflow#="hidden";
} else {
/* [%bs.raw {| document.documentElement.style.overflow = ""|}]; */
ReactDOMRe.domElementToObj(documentElement)##style##overflow#="";
}
)
)
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment