-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (27 loc) · 824 Bytes
/
index.js
File metadata and controls
32 lines (27 loc) · 824 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
/* eslint-disable no-console */
import reactTreeWalker from 'react-tree-walker'
const warnmsg =
'"react-async-bootstrapper" deprecation notice: please rename your "asyncBootstrap" methods to "bootstrap"'
const defaultContext = {
reactAsyncBootstrapperRunning: true,
}
export default function asyncBootstrapper(app, options, context = {}) {
const visitor = (element, instance) => {
if (
instance &&
(typeof instance.asyncBootstrap === 'function' ||
typeof instance.bootstrap === 'function')
) {
return typeof instance.bootstrap === 'function'
? instance.bootstrap()
: console.log(warnmsg) || instance.asyncBootstrap()
}
return undefined
}
return reactTreeWalker(
app,
visitor,
Object.assign({}, context, defaultContext),
options,
)
}