Skip to content

Commit

Permalink
Adds entries for context and instanceID
Browse files Browse the repository at this point in the history
  • Loading branch information
kj committed Nov 17, 2023
1 parent a308542 commit d9cbbca
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/docs/md/elements/state/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ export default function MyElement ({ html, state }) {

</doc-code>

The state object contains two top level entries:
The state object contains four top level entries:

- `attrs`, which contains all the key value pairs of attributes passed into your custom element’s instance
- `store`, which contains the global state of your Enhance application
- `instanceID`, which is a unique ID per instance of Custom Element
- `context`, which is an Object that can be used to pass state to child elements to avoid prop drilling.

These two different entries allow you to work with both basic and complex state in powerful ways without the need for complex abstractions or third party libraries.

Expand Down

0 comments on commit d9cbbca

Please sign in to comment.