-
Notifications
You must be signed in to change notification settings - Fork 0
/
sm-resolver.js
35 lines (30 loc) · 982 Bytes
/
sm-resolver.js
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
import { Fragment } from 'react'
import * as Blurb from './blurb'
const __allSlices = { ...Blurb, }
const NotFound = ({ sliceName, slice, i }) => {
console.error(`[sm-resolver] component "${sliceName}" not found at index ${i}.`)
console.warn(`slice data: ${slice}`)
return process.env.NODE_ENV !== 'production' ? (
<div
style={{
height: '30vh',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
textAlign: 'center',
background: '#FAFAFA'
}}
>
<h2>
Slice "{sliceName}" not found.
</h2>
<p style={{ maxWidth: '320px', fontSize: '16px' }}>
Check that you registered this component in your slices library!
</p>
</div>
) : <Fragment />
}
export default function SliceResolver({ sliceName, ...rest }) {
return __allSlices[sliceName] ? __allSlices[sliceName] : () => <NotFound sliceName={sliceName} {...rest} />
}