Skip to content

Commit

Permalink
Add withReactHydrate
Browse files Browse the repository at this point in the history
  • Loading branch information
zaaack committed Mar 2, 2018
1 parent 53ce7a1 commit 92a7b66
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Binary file modified .paket/paket.exe
Binary file not shown.
12 changes: 12 additions & 0 deletions src/react.fs
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,15 @@ module Program =
)

{ program with setState = setState }

/// Setup rendering of root React component inside html element identified by placeholderId using React.hydrate
let withReactHydrate placeholderId (program:Elmish.Program<_,_,_,_>) =
let setState dispatch =
let viewWithDispatch = program.view dispatch
fun model ->
Fable.Import.ReactDom.hydrate(
lazyViewWith (fun x y -> obj.ReferenceEquals(x,y)) viewWithDispatch model,
document.getElementById(placeholderId)
)

{ program with setState = setState }

0 comments on commit 92a7b66

Please sign in to comment.