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.
- package/package.json +1 -1
- package/readme.md +5 -13
package/package.json
CHANGED
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
|
-
|
|
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
|
|
118
|
+
import layout from 'weg-shared-layout/dummy-data.json';
|
|
120
119
|
|
|
121
120
|
export function SiteFooter() {
|
|
122
|
-
|
|
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
|
-
|
|
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
|
|