Created
April 25, 2018 20:29
-
-
Save geraldodev/37eff01fad48f6d67ca45636355d77b3 to your computer and use it in GitHub Desktop.
Implementation in reason of https://material-ui-next.com/customization/css-in-js/#other-html-element to allow creation of <noscript id="jss-insertion-point> for injecting material-ui at the start of the index.html and let others libraries css taking precedence over material-ui 's
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type jssObj = { | |
. | |
"options": {. [@bs.set] "insertionPoint": Dom.element}, | |
}; | |
[@bs.module "jss"] external createJss : {.} => jssObj = "create"; | |
[@bs.module "material-ui/styles"] | |
external jssPreset : unit => {.} = "jssPreset"; | |
[@bs.module "material-ui/styles"] | |
external createGenerateClassName : unit => string = "createGenerateClassName"; | |
let genClassName = createGenerateClassName(); | |
let jss = createJss(jssPreset()); | |
exception NoScriptIdNotFound(string); | |
let updateInsertionPoint = (noscriptId) => { | |
switch(ReactDOMRe._getElementById(noscriptId)) { | |
| Some(el) => jss##options##insertionPoint#=el | |
| None => raise(NoScriptIdNotFound("noscriptId " ++ noscriptId ++ " not found")) | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment