Feliz.Native 0.0.2-alpha

This is a prerelease version of Feliz.Native.
dotnet add package Feliz.Native --version 0.0.2-alpha
NuGet\Install-Package Feliz.Native -Version 0.0.2-alpha
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Feliz.Native" Version="0.0.2-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Feliz.Native --version 0.0.2-alpha
#r "nuget: Feliz.Native, 0.0.2-alpha"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Feliz.Native as a Cake Addin
#addin nuget:?package=Feliz.Native&version=0.0.2-alpha&prerelease

// Install Feliz.Native as a Cake Tool
#tool nuget:?package=Feliz.Native&version=0.0.2-alpha&prerelease

Feliz.Native

F# binding for writing React Native apps with Fable, based on Feliz.

Currently in a prerelease status at Nuget. Updated as I'm using components in own apps, but feel free to provide a pull request.

Usage and syntax

dotnet add package Feliz.Native --version 0.0.2-alpha

open Feliz
open Feliz.Native

[<ReactComponent>]
let Render () =
    let counter, updateCounter = React.useState 0
    Native.safeAreaView [
        safeAreaView.style [
            style.backgroundColor "#f1f1f1"
        ]
        safeAreaView.children [
            Native.text [text.text "Hello world"]

            // show counter
            Native.text [
                text.children [
                    Native.rawText "Counter:"
                    Native.text [
                        text.style [
                            style.fontSize (length.dip 25)
                            style.color.red
                        ]
                        text.text counter
                    ]
                ]
            ]

            // flex view for buttons
            Native.view [
                view.style [
                    style.flexDirection.row
                    style.alignItems.center
                ]
                view.children [
                    // increment button
                    Native.touchableOpacity [
                        touchableOpacity.onPress (fun () ->
                            counter + 1 |> updateCounter
                        )
                        touchableOpacity.children (
                            Native.text [text.text "+"]
                        )
                    ]

                    // decrement button
                    Native.touchableOpacity [
                        touchableOpacity.style [
                            style.marginLeft (length.dip 10)
                        ]
                        touchableOpacity.onPress (fun () ->
                            counter - 1 |> updateCounter
                        )
                        touchableOpacity.children (
                            Native.text [text.text "+"]
                        )
                    ]
                ]
            ]
        ]
    ]


Helpers.registerApp "DemoApp" (Render ())

See the Fable React Native how-to for an example React Native app with F# and Fable.

Notes

As these bindings are based upon Feliz and prop-layout, using the default value (not providing a length) for pixel based props will cause an error, as Feliz adds px. Use lenght.dip for density independent pixels.

style.fontSize 15 // error, will parse as 15px
style.fontSize (length.dip 15) // ok

style.width 200 // error, will parse as 200px
style.width (length.dip 200) // ok
style.width (length.percent 50) // ok
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.2-alpha 96 4/30/2023
0.0.1-alpha 94 4/25/2023