MCPcopy
hub / github.com/dvajs/dva / start

Function start

packages/dva/src/index.js:44–82  ·  view source on GitHub ↗
(container)

Source from the content-addressed store, hash-verified

42 }
43
44 function start(container) {
45 // 允许 container 是字符串,然后用 querySelector 找元素
46 if (isString(container)) {
47 container = document.querySelector(container);
48 invariant(
49 container,
50 `[app.start] container ${container} not found`,
51 );
52 }
53
54 // 并且是 HTMLElement
55 invariant(
56 !container || isHTMLElement(container),
57 `[app.start] container should be HTMLElement`,
58 );
59
60 // 路由必须提前注册
61 invariant(
62 app._router,
63 `[app.start] router must be registered before app.start()`,
64 );
65
66 if (!app._store) {
67 oldAppStart.call(app);
68 }
69 const store = app._store;
70
71 // export _getProvider for HMR
72 // ref: https://github.com/dvajs/dva/issues/469
73 app._getProvider = getProvider.bind(null, store, app);
74
75 // If has container, render; else, return react component
76 if (container) {
77 render(container, store, app, app._router);
78 app._plugin.apply('onHmr')(render.bind(null, container, store, app));
79 } else {
80 return getProvider(store, this, this._router);
81 }
82 }
83}
84
85function isHTMLElement(node) {

Callers

nothing calls this directly

Calls 5

applyMethod · 0.80
isStringFunction · 0.70
isHTMLElementFunction · 0.70
renderFunction · 0.70
getProviderFunction · 0.70

Tested by

no test coverage detected