({fileMap, entry})
| 168 | } |
| 169 | |
| 170 | runApplication({fileMap, entry}) { |
| 171 | const screenElement = this.refs.root |
| 172 | |
| 173 | if (window._didRegisterComponent) { |
| 174 | this.resetApplication() |
| 175 | } |
| 176 | |
| 177 | this.props.onRun() |
| 178 | |
| 179 | try { |
| 180 | window._require = this.require.bind(this, fileMap, entry) |
| 181 | window._requireCache = {} |
| 182 | window._didRegisterComponent = false |
| 183 | consoleProxy.log = consoleLog.bind(consoleProxy, this.props.id) |
| 184 | consoleProxy.clear = consoleClear.bind(consoleProxy, this.props.id) |
| 185 | |
| 186 | this.evaluate(entry, fileMap[entry]) |
| 187 | |
| 188 | // Attempt to register the default export of the entry file |
| 189 | if (!window._didRegisterComponent) { |
| 190 | const EntryComponent = window._requireCache[entry] |
| 191 | |
| 192 | if (EntryComponent && EntryComponent.default) { |
| 193 | AppRegistry.registerComponent(APP_NAME, () => EntryComponent.default) |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | // If no component was registered, bail out |
| 198 | if (!window._didRegisterComponent) { |
| 199 | return |
| 200 | } |
| 201 | |
| 202 | AppRegistry.runApplication(APP_NAME, { |
| 203 | rootTag: screenElement, |
| 204 | }) |
| 205 | |
| 206 | // After rendering, add {overflow: hidden} to prevent scrollbars |
| 207 | if (screenElement.firstElementChild) { |
| 208 | screenElement.firstElementChild.style.overflow = 'hidden' |
| 209 | } |
| 210 | } catch (e) { |
| 211 | const message = this.buildErrorMessage(e) |
| 212 | this.throwError(message) |
| 213 | this.props.onError(e) |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | resetApplication() { |
| 218 | const screenElement = this.refs.root |
no test coverage detected