Skip to content

[<ReactComponent>]'s caller will fail to pass in a tuple argument. #644

@sheganinans

Description

@sheganinans
open Feliz
open Browser.Dom

[<ReactComponent>]
let Ouch ((a, b, c) : int * string * float) =
  Html.div [ Html.text a; Html.text b; Html.text c ]

let root = ReactDOM.createRoot (document.getElementById "feliz-app")
root.render (Ouch(1, "2", 3.0))

produces the following JS:

import { createElement } from "react";
import React from "react";
import { Interop_reactApi } from "./fable_modules/Feliz.2.6.0/./Interop.fs.js";
import { createRoot } from "react-dom/client";

export function Ouch(ouchInputProps) {
    const _arg1__2 = ouchInputProps._arg1_2;
    const _arg1__1 = ouchInputProps._arg1_1;
    const _arg1_ = ouchInputProps._arg1_0;
    const _arg = [_arg1_, _arg1__1, _arg1__2];
    return createElement("div", {
        children: Interop_reactApi.Children.toArray([_arg[0], _arg[1], _arg[2]]),
    });
}

export const root = createRoot(document.getElementById("feliz-app"));

root.render(createElement(Ouch, {}));

The issue is the last line root.render(createElement(Ouch, {}));:
The generated code passes in an empty object {} into Ouch.

A possible workaround is to make an anonymous struct for these arguments, but I was wondering if this is a bug or if there is a better solution?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions