Skip to content

Allow facets to be used as an initial value of useFacetState#171

Merged
pirelenito merged 5 commits into
mainfrom
facet-state-initial-value
Mar 23, 2026
Merged

Allow facets to be used as an initial value of useFacetState#171
pirelenito merged 5 commits into
mainfrom
facet-state-initial-value

Conversation

@pirelenito
Copy link
Copy Markdown
Member

@pirelenito pirelenito commented Mar 11, 2026

The change ensures that we setup an initial subscription to get the value. Currently achieving the same functionality requires additional effects in user-land code.

const anotherFacet = createFacet({ initialValue: 'initial value' })

const ExampleComponent = () => {
  const [facet, setFacet] = useFacetState(anotherFacet)

  return (
    <span>
      <fast-text text={facet} />
    </span>
  )
}

Copy link
Copy Markdown
Contributor

@Bahamoe Bahamoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition

@pirelenito pirelenito merged commit c22e1e7 into main Mar 23, 2026
26 of 28 checks passed
@pirelenito pirelenito deleted the facet-state-initial-value branch March 23, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants