Giter Site home page Giter Site logo

Inlining const React children about fable HOT 1 OPEN

kerams avatar kerams commented on June 14, 2024
Inlining const React children

from fable.

Comments (1)

MangelMaxime avatar MangelMaxime commented on June 14, 2024

While looking at this issue, I learned for the first time about [<ParamList>] attribute.

According to the changelog and the Fable.Core doc comment, it seems to only exist for Fable.React...

Changelog

## 3.0.0-nagareyama-alpha-003 - 2020-09-14

* Fix: Add names with $reflection suffix to root scope
* Fix deriving from imported JS classes
* Keep support for ParamList attribute until removed from Fable.React

Fable.Core

/// Used to spread the last argument. Mainly intended for `React.createElement` binding, not for general use.
[<AttributeUsage(AttributeTargets.Parameter)>]
type ParamListAttribute() =
    inherit Attribute()

type ParamSeqAttribute = ParamListAttribute

Looking thought the code and after an empiric test,
I am unsure what the effect of [<ParamList>] attributes is, looking through the code it seems to be of the same effect as when we use [<ParamArray>].

IHMO If that's confirmed it would be nice, to remove it in a future major version of Fable.

With that said, while testing what happen if we remove that attribute I discovered that the code should still be working without but it would not save the few extra bytes that you mentioned which is probably not what we want.

// With [<ParamList>]
export function f() {
    const children_4 = [react.createElement("div", {}), react.createElement("span", {})];
    return react.createElement("div", {}, ...children_4);
}

// Without [<ParamList>]
export function f() {
    const children_4 = [react.createElement("div", {}, []), react.createElement("span", {}, [])];
    return react.createElement("div", {}, children_4);
}

// With [<ParamArray>]
export function f() {
    const children_4 = [react.createElement("div", {}), react.createElement("span", {})];
    return react.createElement("div", {}, ...children_4);
}

Regarding the creation of the intermediate variable children_4, I am unsure how Fable decide to create it. What I mean by that is why Fable create a intermediate variable for children and not for the properties object {} in the exemple Without [<ParamList>].

from fable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.