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
// bindings can be isolated/upstreamed. I'm inlining it just for the example | |
type request; | |
type response; | |
[@bs.new] external makeXMLHttpRequest: unit => request = "XMLHttpRequest"; | |
[@bs.send] external addEventListener: (request, string, unit => unit) => unit = "addEventListener"; | |
[@bs.get] external response: request => response = "response"; | |
[@bs.send] external open_: (request, string, string) => unit = "open"; | |
[@bs.send] external send: request => unit = "send"; | |
[@bs.send] external abort: request => unit = "abort"; | |
// ========= |
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
import React from 'react' | |
export default function useDarkMode({ | |
intervalTime = 300, | |
getIsDark = defaultGetIsDark, | |
} = {}) { | |
// Keep track of the current mode | |
const [isDark, setIsDark] = React.useState(() => getIsDark()) | |
// Set up the checker |
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
module StringContext = | |
Context.MakePair({ | |
type t = string; | |
let defaultValue = "Awesome"; | |
}); | |
let component = ReasonReact.statelessComponent("Tree"); | |
let make = _children => { |
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
/* | |
* Define a type that can be either a single string or a list of strings | |
*/ | |
type queryItem = | |
| Single(string) | |
| Multiple(list(string)); | |
/* | |
* Make a string “safe” by |