@croct/plug-react 0.2.3 → 0.4.0
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/README.md +16 -16
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -64,7 +64,6 @@ We suggest putting the `<CroctProvider/ >` somewhere high in your app, above any
|
|
|
64
64
|
ideally in the top-level `<App/>` component.
|
|
65
65
|
|
|
66
66
|
```tsx
|
|
67
|
-
import React from 'react';
|
|
68
67
|
import {render} from 'react-dom';
|
|
69
68
|
import {CroctProvider} from '@croct/plug-react';
|
|
70
69
|
|
|
@@ -97,7 +96,7 @@ and a render function, which tells the component how to render the UI, depending
|
|
|
97
96
|
This is what our component would look like:
|
|
98
97
|
|
|
99
98
|
```tsx
|
|
100
|
-
import {ReactElement,
|
|
99
|
+
import {ReactElement, Suspense} from 'react';
|
|
101
100
|
import {Personalization} from '@croct/plug-react';
|
|
102
101
|
|
|
103
102
|
function OnboardingPage(): ReactElement {
|
|
@@ -117,7 +116,7 @@ function OnboardingPage(): ReactElement {
|
|
|
117
116
|
If you don't want your component to suspend while loading, you can provide an `initial` state to be rendered instead:
|
|
118
117
|
|
|
119
118
|
```tsx
|
|
120
|
-
import {ReactElement
|
|
119
|
+
import {ReactElement} from 'react';
|
|
121
120
|
import {Personalization} from '@croct/plug-react';
|
|
122
121
|
|
|
123
122
|
function OnboardingPage(): ReactElement {
|
|
@@ -135,7 +134,7 @@ function OnboardingPage(): ReactElement {
|
|
|
135
134
|
Now, let's create a `ViewDocsLink` component to see the `useEvaluation` hook in action:
|
|
136
135
|
|
|
137
136
|
```tsx
|
|
138
|
-
import {ReactElement,
|
|
137
|
+
import {ReactElement, Suspense} from 'react';
|
|
139
138
|
import {useEvaluation} from '@croct/plug-react';
|
|
140
139
|
|
|
141
140
|
function ViewDocsLink(): ReactElement {
|
|
@@ -164,13 +163,14 @@ user's profile.
|
|
|
164
163
|
|
|
165
164
|
#### Fault tolerance
|
|
166
165
|
|
|
167
|
-
We strongly recommend
|
|
168
|
-
the personalization. In this way, the UI will still be fully functional even in maintenance
|
|
166
|
+
We strongly recommend specifying the `fallback` property in client-side rendered applications to ensure your app behaves
|
|
167
|
+
the same way regardless of the personalization. In this way, the UI will still be fully functional even in maintenance
|
|
168
|
+
windows. **Specifying a `fallback` is required for server-side rendering (SSR).**
|
|
169
169
|
|
|
170
170
|
The following example shows how you can specify a fallback behaviour for the docs link:
|
|
171
171
|
|
|
172
172
|
```tsx
|
|
173
|
-
import {ReactElement} from 'react';
|
|
173
|
+
import {ReactElement, Fragment, Suspense} from 'react';
|
|
174
174
|
import {Personalization, useEvaluation} from '@croct/plug-react';
|
|
175
175
|
|
|
176
176
|
function ViewDocsLink(): ReactElement {
|
|
@@ -233,7 +233,7 @@ To render the content of the slot, you can either use the `<Slot />` component o
|
|
|
233
233
|
Here's how to use the `<Slot />` component:
|
|
234
234
|
|
|
235
235
|
```tsx
|
|
236
|
-
import {
|
|
236
|
+
import {ReactElement, Suspense} from 'react';
|
|
237
237
|
import {Slot} from '@croct/plug-react';
|
|
238
238
|
|
|
239
239
|
export default function OnboardingPage(): ReactElement {
|
|
@@ -253,10 +253,10 @@ export default function OnboardingPage(): ReactElement {
|
|
|
253
253
|
}
|
|
254
254
|
```
|
|
255
255
|
|
|
256
|
-
To avoid the component
|
|
256
|
+
To avoid the component from suspending while loading, you can provide an `initial` state to be rendered instead:
|
|
257
257
|
|
|
258
258
|
```tsx
|
|
259
|
-
import {
|
|
259
|
+
import {ReactElement} from 'react';
|
|
260
260
|
import {Slot} from '@croct/plug-react';
|
|
261
261
|
|
|
262
262
|
export default function OnboardingPage(): ReactElement {
|
|
@@ -281,7 +281,7 @@ export default function OnboardingPage(): ReactElement {
|
|
|
281
281
|
And here's an example using the `useContent` hook:
|
|
282
282
|
|
|
283
283
|
```tsx
|
|
284
|
-
import {ReactElement} from 'react';
|
|
284
|
+
import {ReactElement, Suspense} from 'react';
|
|
285
285
|
import {useContent} from '@croct/plug-react';
|
|
286
286
|
|
|
287
287
|
function HomeBanner(): ReactElement {
|
|
@@ -310,7 +310,7 @@ export default function HomePage(): ReactElement {
|
|
|
310
310
|
The following example shows how you can specify a fallback state for the `home-banner` slot:
|
|
311
311
|
|
|
312
312
|
```tsx
|
|
313
|
-
import {
|
|
313
|
+
import {ReactElement, Suspense} from 'react';
|
|
314
314
|
import {Slot, useContent} from '@croct/plug-react';
|
|
315
315
|
|
|
316
316
|
const fallbackBanner: HomeBanner = {
|
|
@@ -487,7 +487,7 @@ The component takes the followings properties:
|
|
|
487
487
|
Here's a simple example showing how to evaluate the user's persona:
|
|
488
488
|
|
|
489
489
|
```tsx
|
|
490
|
-
import {ReactElement
|
|
490
|
+
import {ReactElement} from 'react';
|
|
491
491
|
import {Personalization} from '@croct/plug-react';
|
|
492
492
|
|
|
493
493
|
function PersonaBadge(): ReactElement {
|
|
@@ -521,7 +521,7 @@ The component takes the followings properties:
|
|
|
521
521
|
Here's a simple example showing how to render a banner in a slot:
|
|
522
522
|
|
|
523
523
|
```tsx
|
|
524
|
-
import {ReactElement
|
|
524
|
+
import {ReactElement} from 'react';
|
|
525
525
|
import {Slot} from '@croct/plug-react';
|
|
526
526
|
|
|
527
527
|
function HeroBanner(): ReactElement {
|
|
@@ -597,7 +597,7 @@ These are the currently supported options:
|
|
|
597
597
|
Here's a simple example showing how to evaluate the user's persona:
|
|
598
598
|
|
|
599
599
|
```tsx
|
|
600
|
-
import {ReactElement
|
|
600
|
+
import {ReactElement} from 'react';
|
|
601
601
|
import {useEvaluation} from '@croct/plug-react';
|
|
602
602
|
|
|
603
603
|
function PersonaBadge(): ReactElement {
|
|
@@ -632,7 +632,7 @@ These are the currently supported options:
|
|
|
632
632
|
Here's a simple example showing how to fetch the content for a banner:
|
|
633
633
|
|
|
634
634
|
```tsx
|
|
635
|
-
import {ReactElement
|
|
635
|
+
import {ReactElement} from 'react';
|
|
636
636
|
import {useContent} from '@croct/plug-react';
|
|
637
637
|
|
|
638
638
|
function HeroBanner(): ReactElement {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@croct/plug-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "React components and hooks to plug your React applications into Croct.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Croct",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"build-storybook": "build-storybook -s ./.storybook/static"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"react": "^16.8.0 || ^17.0.0",
|
|
38
|
-
"react-dom": "^16.8.0 || ^17.0.0"
|
|
37
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
38
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@croct/plug": "^0.
|
|
41
|
+
"@croct/plug": "^0.10.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@babel/core": "^7.13.13",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"@babel/preset-react": "^7.13.13",
|
|
47
47
|
"@babel/preset-typescript": "^7.13.0",
|
|
48
48
|
"@storybook/addon-actions": "^6.2.3",
|
|
49
|
-
"@storybook/addon-essentials": "^6.
|
|
49
|
+
"@storybook/addon-essentials": "^6.4.13",
|
|
50
50
|
"@storybook/addon-links": "^6.2.3",
|
|
51
|
-
"@storybook/react": "^6.
|
|
51
|
+
"@storybook/react": "^6.4.13",
|
|
52
52
|
"@testing-library/jest-dom": "^5.12.0",
|
|
53
53
|
"@testing-library/react": "^11.2.7",
|
|
54
54
|
"@testing-library/react-hooks": "^7.0.0",
|
|
@@ -73,12 +73,12 @@
|
|
|
73
73
|
"eslint-plugin-standard": "^5.0.0",
|
|
74
74
|
"jest": "26.6.0",
|
|
75
75
|
"jest-environment-node": "^26.6.2",
|
|
76
|
-
"microbundle": "^0.13.
|
|
76
|
+
"microbundle": "^0.13.3",
|
|
77
77
|
"react": "^16.0.0",
|
|
78
78
|
"react-dom": "^16.0.0",
|
|
79
79
|
"ts-node": "^10.0.0",
|
|
80
80
|
"typescript": "^4.1.5",
|
|
81
|
-
"webpack": "
|
|
81
|
+
"webpack": "^5.39.1"
|
|
82
82
|
},
|
|
83
83
|
"files": [
|
|
84
84
|
"**/*.js",
|