File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111'use strict' ;
1212
1313const DevSettings = require ( './DevSettings' ) ;
14- const Platform = require ( './Platform' ) ;
1514const invariant = require ( 'invariant' ) ;
16-
1715const MetroHMRClient = require ( 'metro/src/lib/bundle-modules/HMRClient' ) ;
16+ const Platform = require ( './Platform' ) ;
17+ const prettyFormat = require ( 'pretty-format' ) ;
1818
1919import NativeRedBox from '../NativeModules/specs/NativeRedBox' ;
2020import * as LogBoxData from '../LogBox/Data/LogBoxData' ;
@@ -114,36 +114,23 @@ const HMRClient: HMRClientNativeInterface = {
114114 return ;
115115 }
116116 try {
117- let message ;
118- if ( global . Symbol ) {
119- message = JSON . stringify ( {
117+ hmrClient . send (
118+ JSON . stringify ( {
120119 type : 'log' ,
121120 level,
122121 data : data . map ( item =>
123122 typeof item === 'string'
124123 ? item
125- : require ( 'pretty-format' ) ( item , {
124+ : prettyFormat ( item , {
126125 escapeString : true ,
127126 highlight : true ,
128127 maxDepth : 3 ,
129128 min : true ,
130- plugins : [ require ( 'pretty-format' ) . plugins . ReactElement ] ,
129+ plugins : [ prettyFormat . plugins . ReactElement ] ,
131130 } ) ,
132131 ) ,
133- } ) ;
134- } else {
135- try {
136- message = JSON . stringify ( { type : 'log' , level, data} ) ;
137- } catch ( error ) {
138- message = JSON . stringify ( {
139- type : 'log' ,
140- level,
141- data : [ error . message ] ,
142- } ) ;
143- }
144- }
145-
146- hmrClient . send ( message ) ;
132+ } ) ,
133+ ) ;
147134 } catch ( error ) {
148135 // If sending logs causes any failures we want to silently ignore them
149136 // to ensure we do not cause infinite-logging loops.
You can’t perform that action at this time.
0 commit comments