Skip to content

Commit

Permalink
Use dedicated file for React functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrattli committed Jun 14, 2020
1 parent f9a2d3d commit cce0710
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Feliz.ViewEngine.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<Compile Include="Fonts.fs" />
<Compile Include="StyleTypes.fs" />
<Compile Include="Interop.fs" />
<Compile Include="React.fs" />
<Compile Include="Styles.fs" />
<Compile Include="TextDecorationLine.fs" />
<Compile Include="TextDecorationStyle.fs" />
Expand Down
4 changes: 0 additions & 4 deletions src/Interop.fs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ type FunctionComponent<'Props> = 'Props -> ReactElement

// fsharplint:disable

type React =
static member functionComponent(name: string, render: 'props -> ReactElement) : FunctionComponent<'props> =
render

type Event () = class end
with
member x.preventDefault () = ()
Expand Down
44 changes: 44 additions & 0 deletions src/React.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
namespace Feliz.ViewEngine

open System

//fsharplint:disable

type React =
/// <summary>
/// Creates a React function component from a function that accepts a "props" object and renders a result.
/// A component key can be provided in the props object, or a custom `withKey` function can be provided.
/// </summary>
/// <param name='render'>A render function that returns an element.</param>
/// <param name='withKey'>A function to derive a component key from the props.</param>
static member functionComponent(render: 'props -> ReactElement, ?withKey: 'props -> string) =
render

/// <summary>
/// Creates a React function component from a function that accepts a "props" object and renders a result.
/// A component key can be provided in the props object, or a custom `withKey` function can be provided.
/// </summary>
/// <param name='name'>The component name to display in the React dev tools.</param>
/// <param name='render'>A render function that returns an element.</param>
/// <param name='withKey'>A function to derive a component key from the props.</param>
static member functionComponent(name: string, render: 'props -> ReactElement, ?withKey: 'props -> string) =
render

/// <summary>
/// Creates a React function component from a function that accepts a "props" object and renders a result.
/// A component key can be provided in the props object, or a custom `withKey` function can be provided.
/// </summary>
/// <param name='render'>A render function that returns a list of elements.</param>
/// <param name='withKey'>A function to derive a component key from the props.</param>
static member functionComponent(render: 'props -> #seq<ReactElement>, ?withKey: 'props -> string) =
render

/// <summary>
/// Creates a React function component from a function that accepts a "props" object and renders a result.
/// A component key can be provided in the props object, or a custom `withKey` function can be provided.
/// </summary>
/// <param name='render'>A render function that returns a list of elements.</param>
/// <param name='name'>The component name to display in the React dev tools.</param>
/// <param name='withKey'>A function to derive a component key from the props.</param>
static member functionComponent(name: string, render: 'props -> #seq<ReactElement>, ?withKey: 'props -> string) =
render

0 comments on commit cce0710

Please sign in to comment.