-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathIsomorphicImport.njs
More file actions
38 lines (31 loc) · 999 Bytes
/
IsomorphicImport.njs
File metadata and controls
38 lines (31 loc) · 999 Bytes
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
import Nullstack from 'nullstack'
import { clientOnly, clientOnly as clientOnlyAlias, serverOnly, serverOnly as serverOnlyAlias } from './helpers'
import * as namespacedImport from './helpers'
class IsomorphicImport extends Nullstack {
static async serverFunction() {
return {
serverOnly: serverOnly(),
serverOnlyAlias: serverOnlyAlias(),
namespacedServerOnly: namespacedImport.serverOnly(),
}
}
async initiate() {
const data = await this.serverFunction()
Object.assign(this, data)
this.clientOnly = clientOnly()
this.clientOnlyAlias = clientOnlyAlias()
}
render() {
return (
<div
data-hydrated={this.hydrated}
data-server-only={this.serverOnly}
data-server-only-alias={this.serverOnlyAlias}
data-client-only={this.clientOnly}
data-client-only-alias={this.clientOnlyAlias}
data-namespaced-server-only={this.namespacedServerOnly}
/>
)
}
}
export default IsomorphicImport