Skip to content

Commit 54453cc

Browse files
Publish Fable.React 4.1.1
1 parent 1d424cb commit 54453cc

File tree

5 files changed

+53
-41
lines changed

5 files changed

+53
-41
lines changed

src/Fable.React/Fable.Helpers.Isomorphic.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ module Components =
1919
inherit Component<HybridProps<'P>, HybridState>(initProps) with
2020
do this.setInitState { isClient=false }
2121

22-
override x.componentDidMount() =
23-
this.setState { isClient=true }
22+
override __.componentDidMount() =
23+
this.setState(fun _ _ -> { isClient=true })
2424

2525
override x.render() =
2626
if x.state.isClient

src/Fable.React/Fable.Helpers.React.fs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ module rec Props =
164164

165165
type HTMLAttr =
166166
| DefaultChecked of bool
167-
| DefaultValue of string
167+
| DefaultValue of obj
168168
| Accept of string
169169
| AcceptCharset of string
170170
| AccessKey of string
@@ -188,8 +188,8 @@ module rec Props =
188188
| ClassName of string
189189
/// Alias of ClassName
190190
| [<CompiledName("className")>] Class of string
191-
| Cols of float
192-
| ColSpan of float
191+
| Cols of int
192+
| ColSpan of int
193193
| Content of string
194194
| ContentEditable of bool
195195
| ContextMenu of string
@@ -259,8 +259,8 @@ module rec Props =
259259
| Rel of string
260260
| Required of bool
261261
| Role of string
262-
| Rows of float
263-
| RowSpan of float
262+
| Rows of int
263+
| RowSpan of int
264264
| Sandbox of string
265265
| Scope of string
266266
| Scoped of bool
@@ -279,12 +279,12 @@ module rec Props =
279279
| Start of float
280280
| Step of obj
281281
| Summary of string
282-
| TabIndex of float
282+
| TabIndex of int
283283
| Target of string
284284
| Title of string
285285
| Type of string
286286
| UseMap of string
287-
| Value of string
287+
| Value of obj
288288
| Width of obj
289289
| Wmode of string
290290
| Wrap of string
@@ -1096,9 +1096,14 @@ let inline mountBySelector (domElSelector: string) (reactEl: ReactElement): unit
10961096

10971097
type Fable.Import.React.FormEvent with
10981098
/// Access the value from target
1099-
/// Equivalent to `unbox<string> this.target?value`
1099+
/// Equivalent to `(this.target :?> Browser.HTMLInputElement).value`
11001100
member this.Value =
1101-
unbox<string> this.target?value
1101+
(this.target :?> Browser.HTMLInputElement).value
1102+
1103+
/// Access the checked property from target
1104+
/// Equivalent to `(this.target :?> Browser.HTMLInputElement).checked`
1105+
member this.Checked =
1106+
(this.target :?> Browser.HTMLInputElement).``checked``
11021107

11031108
// Helpers for ReactiveComponents (see #44)
11041109
module ReactiveComponents =
@@ -1133,7 +1138,7 @@ type ReactiveCom<'P, 'S, 'Msg>(initProps) =
11331138
children = this.children }
11341139
this.props.view model (fun msg ->
11351140
let newState = this.props.update msg this.state.value
1136-
this.setState({ value = newState }))
1141+
this.setState(fun _ _ -> { value = newState }))
11371142

11381143
/// Renders a stateful React component from functions similar to Elmish
11391144
/// * `init` - Initializes component state with given props

src/Fable.React/Fable.Helpers.ReactServer.fs

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module Fable.Helpers.ReactServer
22

3-
open System
43
open System.IO
54
open System.Text.RegularExpressions
65

@@ -467,7 +466,7 @@ let inline objAttr (html:TextWriter) (key: string) (value: obj) = strAttr html k
467466
let private renderHtmlAttr (html:TextWriter) (attr: HTMLAttr) =
468467
match attr with
469468
| DefaultChecked v | Checked v -> boolAttr html "checked" v
470-
| DefaultValue v | Value v -> strAttr html "value" v
469+
| DefaultValue v | Value v -> strAttr html "value" (string v)
471470
| Accept v -> strAttr html "accept" v
472471
| AcceptCharset v -> strAttr html "accept-charset" v
473472
| AccessKey v -> strAttr html "accesskey" v
@@ -700,7 +699,7 @@ let private renderAttrs (html:TextWriter) (attrs: IProp seq) tag =
700699
match tag, attr with
701700
| "textarea", Value v
702701
| "textarea", DefaultValue v ->
703-
childHtml <- Some v
702+
childHtml <- Some(string v)
704703
| _, _ ->
705704
html.Write ' '
706705
renderHtmlAttr html attr
@@ -726,37 +725,39 @@ let inline private castHTMLNode (htmlNode: ReactElement): HTMLNode =
726725
else
727726
htmlNode :?> HTMLNode
728727

729-
let rec writeTo (html: TextWriter) (htmlNode: HTMLNode) : unit =
730-
match htmlNode with
731-
| HTMLNode.Text str -> escapeHtml html str
732-
| HTMLNode.RawText str -> html.Write str
733-
| HTMLNode.Node (tag, attrs, children) ->
734-
html.Write '<'
735-
html.Write tag
728+
module Raw =
729+
/// Writes the nodes into a TextWriter. DOESN'T ADD `reactroot` attribute.
730+
let rec writeTo (html: TextWriter) (htmlNode: HTMLNode) : unit =
731+
match htmlNode with
732+
| HTMLNode.Text str -> escapeHtml html str
733+
| HTMLNode.RawText str -> html.Write str
734+
| HTMLNode.Node (tag, attrs, children) ->
735+
html.Write '<'
736+
html.Write tag
736737

737-
let child = renderAttrs html attrs tag
738+
let child = renderAttrs html attrs tag
738739

739-
if voidTags.Contains tag then
740-
html.Write "/>"
741-
else
742-
html.Write '>'
740+
if voidTags.Contains tag then
741+
html.Write "/>"
742+
else
743+
html.Write '>'
743744

744-
match child with
745-
| Some c -> html.Write c
746-
| None ->
747-
for child in children do
748-
writeTo html (castHTMLNode child)
745+
match child with
746+
| Some c -> html.Write c
747+
| None ->
748+
for child in children do
749+
writeTo html (castHTMLNode child)
749750

750-
html.Write "</"
751-
html.Write tag
752-
html.Write '>'
753-
| HTMLNode.List nodes ->
754-
for node in nodes do
755-
writeTo html (castHTMLNode node)
756-
| HTMLNode.Empty -> ()
751+
html.Write "</"
752+
html.Write tag
753+
html.Write '>'
754+
| HTMLNode.List nodes ->
755+
for node in nodes do
756+
writeTo html (castHTMLNode node)
757+
| HTMLNode.Empty -> ()
757758

758759
let renderToString (htmlNode: ReactElement): string =
759760
let htmlNode = addReactMark (castHTMLNode htmlNode)
760761
use html = new StringWriter()
761-
htmlNode |> writeTo html
762+
htmlNode |> Raw.writeTo html
762763
html.ToString()

src/Fable.React/Fable.React.fsproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<Version>4.0.1</Version>
4+
<Version>4.1.1</Version>
5+
<PackageVersion>4.1.1</PackageVersion>
56
<TargetFrameworks>netstandard2.0</TargetFrameworks>
67
<GenerateDocumentationFile>true</GenerateDocumentationFile>
78
</PropertyGroup>

src/Fable.React/RELEASE_NOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### 4.1.1
2+
3+
* Mark `setState: 'S` as obsolete @SirUppyPancakes
4+
* Enable writing into a TextWritter in SSR @thinkbeforecoding
5+
16
### 4.0.1
27

38
* Update Fable 2 deps to stable version

0 commit comments

Comments
 (0)