Skip to content
Discussion options

You must be logged in to vote

No problem. And there is luckily an easy solution. Unfortunately you have run into the likely biggest gotcha with the approach Solid uses. This is shared by Vue and MobX too. We can't destructure props without losing reactivity. The button component needs to look like:

function Button(props) {
  return (
    <button class='Button' data-progress={props.progress}>
      {props.children}
    </button>
  )
}

I've tried to note this in the docs in several locations but I feel like it's a 50/50 whether people see this.

More detailed explanation:

It isn't the destructure itself doesn't work. It is that tracking for updates happens on property access, so if you reference them outside of a JSX bin…

Replies: 4 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by ryansolid
Comment options

You must be logged in to vote
5 replies
@ryansolid
Comment options

@aminya
Comment options

@ryansolid
Comment options

@aminya
Comment options

@ryansolid
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@MattStopa
Comment options

@xdev1
Comment options

@MattStopa
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants