Closed vbfox closed 5 years ago
Nice one, thank you!
awesome this reduces couple of yields for me. How can we make it mor popular? @theimowski something for the template?
Yeah, maybe - created an issue
Just for reference you can also use Option.map
to not use yield
.
let private showFirstConnectionUrl (url : string) =
Message.message [ Message.Color IsInfo ]
[ Message.header [ ]
[ str "Ce compte n'a pas encore été activé." ]
Message.body [ ]
[ CopyButton.copyButtton [ CopyButton.Value url ] ] ]
let private viewUserInfo (info : LoadedModel) dispatch =
div [ ]
[ info.OriginalData.FirstConnectionUrl
|> Option.map showFirstConnectionUrl
|> ofOption
// More code...
]
Yes, but really like the explicit nothing function.
Am Di., 6. Nov. 2018, 11:05 hat Maxime Mangel notifications@github.com geschrieben:
Just for reference you can also use Option.map to not use yield.
let private showFirstConnectionUrl (url : string) = Message.message [ Message.Color IsInfo ] [ Message.header [ ] [ str "Ce compte n'a pas encore été activé." ] Message.body [ ] [ CopyButton.copyButtton [ CopyButton.Value url ] ] ] let private viewUserInfo (info : LoadedModel) dispatch = div [ ] [ info.OriginalData.FirstConnectionUrl |> Option.map showFirstConnectionUrl |> ofOption // More code... ]
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fable-compiler/fable-react/pull/113#issuecomment-436198121, or mute the thread https://github.com/notifications/unsubscribe-auth/AADgNDz1JH9eBFaCzR7UcmbO7xbhLl8Yks5usV7dgaJpZM4YPTYX .
Yes using Option.Map + ofOption
is the other choice but for complex case I find nothing
to be clearer and producing less noise instead having to add Some
/None
+ ofOption
, when starting with options in the model then it depends
Currently in SAFE template and its "counter" example there's a little potential of usage for nothing
. I found a single place where yield
was used for --layout fulma-hero
: https://github.com/SAFE-Stack/SAFE-template/pull/175/files#diff-0ff6c3d1f6fb2e5a81ccfc138c7e76a1R593
Surely in future e.g. when we move away from "counter" example, nothing
may turn out more handy
React use
null
to signal that nothing should be rendered, it could be done before withofOption None
but this add clearer alternative to generate this.