-
Notifications
You must be signed in to change notification settings - Fork 0
/
Nosto404.tsx
47 lines (43 loc) · 1.37 KB
/
Nosto404.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { useNostoContext } from "./context"
import { useNostoApi } from "../utils/hooks"
/**
* You can personalise your cart and checkout pages by using the `Nosto404` component.
* The component does not require any props.
*
* By default, your account, when created, has three 404-page placements named `notfound-nosto-1`, `notfound-nosto-2` and `notfound-nosto-3`.
* You may omit these and use any identifier you need.
* The identifiers used here are simply provided to illustrate the example.
*
* @example
* ```
* <div className="notfound-page">
* <NostoPlacement id="notfound-nosto-1" />
* <NostoPlacement id="notfound-nosto-2" />
* <NostoPlacement id="notfound-nosto-3" />
* <Nosto404 />
* </div>
* ```
*
* @group Components
*/
export default function Nosto404(props: { placements?: string[] }) {
const { recommendationComponent, useRenderCampaigns } = useNostoContext()
const { renderCampaigns, pageTypeUpdated } = useRenderCampaigns("404")
useNostoApi(
async (api) => {
const data = await api.defaultSession()
.viewNotFound()
.setPlacements(props.placements || api.placements.getPlacements())
.load()
renderCampaigns(data, api)
},
[recommendationComponent, pageTypeUpdated]
)
return (
<>
<div className="nosto_page_type" style={{ display: "none" }}>
notfound
</div>
</>
)
}