facebook / jsx

The JSX specification is a XML-like syntax extension to ECMAScript.

Home Page:http://facebook.github.io/jsx/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get accessor in props

d8corp opened this issue · comments

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)

commented

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.