GithubHelp home page GithubHelp logo

Investigate functional components about destiny HOT 5 CLOSED

0kku avatar 0kku commented on August 23, 2024
Investigate functional components

from destiny.

Comments (5)

ebebbington avatar ebebbington commented on August 23, 2024

@0kku coming from a react background, this approach seems nice and I guess it feels cleaner, and I’d enjoy writing components this way, but in my opinion, the thing that makes me love destiny is how native it is, everything nowadays are just polyfills and ‘fake native implementations’, a component not being a class and not being able to extend a html element does quite the opposite, it removed the native aspect of it and possibly feels like ‘magic’

I’m torn, but would be curious to hear you thoughts on the above

from destiny.

0kku avatar 0kku commented on August 23, 2024

@0kku coming from a react background, this approach seems nice and I guess it feels cleaner, and I’d enjoy writing components this way, but in my opinion, the thing that makes me love destiny is how native it is, everything nowadays are just polyfills and ‘fake native implementations’, a component not being a class and not being able to extend a html element does quite the opposite, it removed the native aspect of it and possibly feels like ‘magic’

I’m torn, but would be curious to hear you thoughts on the above

Just to be clear: the component would still extend HTMLElement after instantiation, but wouldn't be doing so until after the component has been passed to the template. The intention of the idea was for it to convert the function into a class that extends HTMLElement under the hood. However, I do see your concerns regardless. Also, this conversion would be a non-zero amount of work, so technically it would have slightly more overhead as well.

from destiny.

0kku avatar 0kku commented on August 23, 2024

By the way, something like this would already work for things that don't require lifecycle hooks, since all these things are nothing but JS values:

import { html } from "destiny";

function myTemplate (defaultName: string) {
  const who = reactive(defaultName);

  return html`
    <label>What's your name? <input type="text" value=${who} /></label>
    <p>
      Hello, ${who}!
    </p>
  `;
}

function anotherTemplate () {
  return html`
    <h1>Demo</h1>
    ${myTemplate("visitor")}
  `;
}

document.body.append(anotherTemplate().content);

from destiny.

ebebbington avatar ebebbington commented on August 23, 2024

Yeah fair enough, I do see the functional components being nicer in every way, plus I guess it means you pass in values (like above) as opposed to using custom attributes

I’m warming towards functional components now :) imo

from destiny.

0kku avatar 0kku commented on August 23, 2024

Closed as infeasible and too magical (the bad kind).

from destiny.

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.