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

Function start

packages/dva-no-router/src/index.js:23–61  ·  view source on GitHub ↗
(container)

Source from the content-addressed store, hash-verified

21 }
22
23 function start(container) {
24 // 允许 container 是字符串,然后用 querySelector 找元素
25 if (isString(container)) {
26 container = document.querySelector(container);
27 invariant(
28 container,
29 `[app.start] container ${container} not found`,
30 );
31 }
32
33 // 并且是 HTMLElement
34 invariant(
35 !container || isHTMLElement(container),
36 `[app.start] container should be HTMLElement`,
37 );
38
39 // 路由必须提前注册
40 invariant(
41 app._router,
42 `[app.start] router must be registered before app.start()`,
43 );
44
45 if (!app._store) {
46 oldAppStart.call(app);
47 }
48 const store = app._store;
49
50 // export _getProvider for HMR
51 // ref: https://github.com/dvajs/dva/issues/469
52 app._getProvider = getProvider.bind(null, store, app);
53
54 // If has container, render; else, return react component
55 if (container) {
56 render(container, store, app, app._router);
57 app._plugin.apply('onHmr')(render.bind(null, container, store, app));
58 } else {
59 return getProvider(store, this, this._router);
60 }
61 }
62}
63
64function 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