weg-shared-layout 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/readme.md +5 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weg-shared-layout",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Shared layout Web Components built with Stencil",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
package/readme.md CHANGED
@@ -103,7 +103,7 @@ Add `CUSTOM_ELEMENTS_SCHEMA` once on the module that declares components using `
103
103
 
104
104
  ## Using in React
105
105
 
106
- Register once (for example in your app entry):
106
+ Register the element once (for example in `main.tsx` / your app entry):
107
107
 
108
108
  ```ts
109
109
  import { defineCustomElements } from 'weg-shared-layout/loader';
@@ -111,26 +111,18 @@ import { defineCustomElements } from 'weg-shared-layout/loader';
111
111
  defineCustomElements();
112
112
  ```
113
113
 
114
- Pass an object via a **ref** (or use React 19+ property handling) so you set the DOM property, not a string attribute:
114
+ Import the fixture (or your own object with the same shape) and pass it on **`data`**:
115
115
 
116
116
  ```tsx
117
- import { useEffect, useRef, useState } from 'react';
118
117
  import 'weg-shared-layout/weg-footer';
119
- import layoutFixture from 'weg-shared-layout/dummy-data.json';
118
+ import layout from 'weg-shared-layout/dummy-data.json';
120
119
 
121
120
  export function SiteFooter() {
122
- const ref = useRef<HTMLElement & { data?: unknown }>(null);
123
- const [layout, setLayout] = useState(layoutFixture);
124
-
125
- useEffect(() => {
126
- if (ref.current) ref.current.data = layout;
127
- }, [layout]);
128
-
129
- return <weg-footer ref={ref} />;
121
+ return <weg-footer data={layout} />;
130
122
  }
131
123
  ```
132
124
 
133
- Swap `layoutFixture` / `setLayout` for your own data loading. **Next.js App Router:** register and assign `data` only in a Client Component (`"use client"`).
125
+ Use **React 19 or newer** so `data={...}` is applied as the custom element’s **`data` property** (object), not a string attribute. Register the elements in a **Client Component** only (`"use client"` in the Next.js App Router).
134
126
 
135
127
  ### React TypeScript
136
128