facebook / jsx

The JSX specification is a XML-like syntax extension to ECMAScript.
http://facebook.github.io/jsx/
1.95k stars 133 forks source link

Get accessor in props #125

Open d8corp opened 4 years ago

d8corp commented 4 years ago

Could you add a syntaxis to have get accessor in props?

let count = 0
const test = <div test=${count++} />

I wanna increase the count each time I get the property of test.

const props = {
  get test () {
    return count++
  }
}

It will help to change one attribute of element instead of full rerendering (all attributs and childrens)

QbDesu commented 2 years ago

Let's review the technical requirements that would be necessary to implement such a feature: In order for this to work intrinsics <a href=${this.b}> as well as components <MyComponent someProp=${this.b}> it would require passing the props as a proxy with overridden get accessors for the prop in question. Not to mention a couple of things would break. What would cause the child component to rerender if the value changes? Implications for the lifecycle of the child,.. etc.