package jsoo-react

  1. Overview
  2. Docs
Bindings to ReactJS for js_of_ocaml, including JSX ppx

Install

Dune Dependency

Authors

Maintainers

Sources

0.1.tar.gz
sha256=93d5751c01016f5aa018b80259df0c65ac12f25152cef1dbcff024ddfc1f07b5
md5=240fd3b58cb002ff7eaa6ddddb7eba87

doc/jsoo-react.lib/React/Router/index.html

Module React.RouterSource

Sourceval push : string -> unit

update the url with the string path. Example: `push("/book/1")`, `push("/books#title")`

Sourceval replace : string -> unit

update the url with the string path. modifies the current history entry instead of creating a new one. Example: `replace("/book/1")`, `replace("/books#title")`

Sourcetype watcher_id
Sourcetype url = {
  1. path : string list;
  2. hash : string;
  3. search : string;
}
Sourceval watch_url : (url -> unit) -> watcher_id

start watching for URL changes. Returns a subscription token. Upon url change, calls the callback and passes it the url record

Sourceval unwatch_url : watcher_id -> unit

stop watching for URL changes

Sourceval dangerously_get_initial_url : unit -> url

this is marked as "dangerous" because you technically shouldn't be accessing the URL outside of watchUrl's callback; you'd read a potentially stale url, instead of the fresh one inside watchUrl. But this helper is sometimes needed, if you'd like to initialize a page whose display/state depends on the URL, instead of reading from it in watchUrl's callback, which you'd probably have put inside didMount (aka too late, the page's already rendered). So, the correct (and idiomatic) usage of this helper is to only use it in a component that's also subscribed to watchUrl. Please see https://github.com/reasonml-community/reason-react-example/blob/master/src/todomvc/TodoItem.re for an example.

Sourceval use_url : ?server_url:url -> unit -> url

hook for watching url changes. * serverUrl is used for ssr. it allows you to specify the url without relying on browser apis existing/working as expected

OCaml

Innovation. Community. Security.