FreeAct 0.3.1
dotnet add package FreeAct --version 0.3.1
NuGet\Install-Package FreeAct -Version 0.3.1
<PackageReference Include="FreeAct" Version="0.3.1" />
<PackageVersion Include="FreeAct" Version="0.3.1" />
<PackageReference Include="FreeAct" />
paket add FreeAct --version 0.3.1
#r "nuget: FreeAct, 0.3.1"
#:package FreeAct@0.3.1
#addin nuget:?package=FreeAct&version=0.3.1
#tool nuget:?package=FreeAct&version=0.3.1
FreeAct
A DSL for creating React components in F#.
Usage
FreeAct is a DSL (Domain Specific Language) for building React applications in F# that provides:
- Component creation with a clean, F#-friendly syntax
- Built-in routing system
- State management with FreeFrame
- Type-safe styling with FreeSS
- Full integration with React ecosystem
Overview
FreeAct is an opinionated F# library for building React applications that aims to provide a simpler alternative to existing solutions while maintaining type safety and separation of concerns. It consists of three main modules:
FreeAct Core
A clean alternative to JSX or Feliz for creating React elements with a straightforward, F#-native syntax. Eliminates common pain points and provides a more intuitive API for F# developers.
FreeFrame
A state management solution inspired by Re-Frame, offering a cleaner separation between rendering logic and application state. Unlike Elmish, FreeFrame promotes:
- Clear separation of concerns between state and view logic
- Simplified state updates through events and reducers
- Reactive views with automatic updates
- Composable state subscriptions
FreeSS
A strongly-typed CSS-in-F# solution that provides:
- Full type safety for CSS properties and values
- F#-native syntax for defining styles
- Composition and reuse of style definitions
- No runtime overhead
Installation
dotnet add package FreeAct
Basic Usage
Here's a simple example showing the three main components working together:
open FreeAct
open FreeFrame
open FreeSS
// Define styles
let styles = style {
display Display.Flex
flexDirection FlexDirection.Column
padding (Spacing.All 10)
}
// Define state management
type CounterEvent =
| Increment
| Decrement
// Create a view component
let Counter() =
div {
className styles
button {
onClick (fun _ -> dispatch CounterEvent.Increment)
text "+"
}
span {
text (string count)
}
button {
onClick (fun _ -> dispatch CounterEvent.Decrement)
text "-"
}
}
Documentation
For more detailed documentation on each module:
- FreeAct Core - React element creation
- FreeFrame - State management
- FreeSS - Styling system
Features
Component Creation
- Clean, F#-native syntax for React components
- Strong type inference
- No JSX required
- Full access to React hooks and lifecycle methods
- Component composition with type-safe props
Routing
- First-class routing support
- Type-safe route parameters
- Nested routes
- Query parameter handling
- Route-based code splitting
State Management (FreeFrame)
- Event-driven architecture
- Pure reducers for state updates
- Automatic view updates
- Side-effect management
- State composition
- Time-travel debugging ready
Styling (FreeSS)
- Type-safe CSS properties
- Style composition
- Media queries support
- Pseudo-selectors
- Dynamic styles
- Zero runtime overhead
- Scoped class names
Examples
Our Todo application demonstrates the core features working together:
// Define state
type Todo = { id: int; text: string; completed: bool }
type TodoEvent =
| Add of string
| Toggle of int
| Delete of int
// Define styles
let todoItem = style {
display Display.Flex
alignItems AlignItems.Center
padding (Spacing.All 8)
borderBottom "1px solid #eee"
}
// Create components
let TodoList() =
let todos = useView todosSubscription
div {
ul {
className "todo-list"
children (
todos |> List.map (fun todo ->
li {
className todoItem
input {
type' InputType.Checkbox
checked todo.completed
onChange (fun _ -> dispatch (Toggle todo.id))
}
span { text todo.text }
button {
onClick (fun _ -> dispatch (Delete todo.id))
text "×"
}
}
)
)
}
}
For more examples, check out our demo application.
Contributing
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
dotnet test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please make sure to update tests as appropriate and follow our coding standards.
License
Distributed under the MIT License. See LICENSE file for more information.
| Product | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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. |
-
.NETStandard 2.1
- Fable.Core (>= 4.5.0)
- Fable.Package.SDK (>= 1.0.0)
- Fable.React (>= 9.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.