Skip to content

Commit

Permalink
Add Impossible_in_ssr for render/hydrate
Browse files Browse the repository at this point in the history
  • Loading branch information
davesnx committed Aug 7, 2023
1 parent 9198350 commit 8200204
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
9 changes: 6 additions & 3 deletions packages/js/js.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
exception Not_implemented of string

let notImplemented module_ function_ =
failwith
(Printf.sprintf "'%s.%s' is not implemented in server-reason-react" module_
function_)
raise
(Not_implemented
(Printf.sprintf "'%s.%s' is not implemented in server-reason-react"
module_ function_))

type 'a t = < .. > as 'a

Expand Down
16 changes: 7 additions & 9 deletions packages/reactDom/src/reactDOM.ml
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,14 @@ let renderToLwtStream element =

let querySelector _str = None

let fail_impossible_action_in_ssr =
(* failwith seems bad, but I don't know any other way
of warning the user without changing the types. Doing a unit *)
(* failwith
(Printf.sprintf "render shouldn't run on the server %s, line %d" __FILE__
__LINE__) *)
()
exception Impossible_in_ssr of string

let render _element _node = fail_impossible_action_in_ssr
let hydrate _element _node = fail_impossible_action_in_ssr
let fail_impossible_action_in_ssr fn =
let msg = Printf.sprintf "'%s' shouldn't run on the server" fn in
raise (Impossible_in_ssr msg)

let render _element _node = fail_impossible_action_in_ssr "ReactDOM.render"
let hydrate _element _node = fail_impossible_action_in_ssr "ReactDOM.hydrate"
let createPortal _reactElement _domElement = _reactElement

module Style = ReactDOMStyle
Expand Down

0 comments on commit 8200204

Please sign in to comment.