File tree Expand file tree Collapse file tree
packages/domscribe-transform/src/plugins Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -304,6 +304,23 @@ export function domscribe(options: VitePluginOptions = {}): Plugin {
304304 transformIndexHtml ( ) : IndexHtmlTransformResult | undefined {
305305 const tags : HtmlTagDescriptor [ ] = [ ] ;
306306
307+ // Suppress React's "Invalid prop `data-ds` supplied to React.Fragment"
308+ // warning. Fires when a component resolves to Fragment at runtime
309+ // (e.g. `const P = hasKey ? dynamic(...) : Fragment`). Harmless but
310+ // clutters the console and triggers error overlays.
311+ tags . push ( {
312+ tag : 'script' ,
313+ children :
314+ `if(!window.__DOMSCRIBE_CONSOLE_PATCHED__){` +
315+ `window.__DOMSCRIBE_CONSOLE_PATCHED__=true;` +
316+ `var _ce=console.error;` +
317+ `console.error=function(){` +
318+ `if(typeof arguments[0]==='string'&&arguments[0].indexOf('data-ds')!==-1&&arguments[0].indexOf('React.Fragment')!==-1)return;` +
319+ `return _ce.apply(console,arguments)` +
320+ `}}` ,
321+ injectTo : 'head-prepend' ,
322+ } ) ;
323+
307324 // Inject relay port for overlay discovery
308325 // The overlay (browser UI) needs to know which port to connect to
309326 if ( relayPort && relayHost ) {
@@ -338,10 +355,7 @@ export function domscribe(options: VitePluginOptions = {}): Plugin {
338355 } ) ;
339356 }
340357
341- if ( tags . length > 0 ) {
342- return { html : '' , tags } ;
343- }
344- return undefined ;
358+ return { html : '' , tags } ;
345359 } ,
346360 } ;
347361}
Original file line number Diff line number Diff line change @@ -268,6 +268,21 @@ export class DomscribeWebpackPlugin {
268268 const headTags : string [ ] = [ ] ;
269269 const bodyTags : string [ ] = [ ] ;
270270
271+ // Suppress React's "Invalid prop `data-ds` supplied to React.Fragment"
272+ // warning. Fires when a component resolves to Fragment at runtime
273+ // (e.g. `const P = hasKey ? dynamic(...) : Fragment`).
274+ headTags . push (
275+ `<script>` +
276+ `if(!window.__DOMSCRIBE_CONSOLE_PATCHED__){` +
277+ `window.__DOMSCRIBE_CONSOLE_PATCHED__=true;` +
278+ `var _ce=console.error;` +
279+ `console.error=function(){` +
280+ `if(typeof arguments[0]==='string'&&arguments[0].indexOf('data-ds')!==-1&&arguments[0].indexOf('React.Fragment')!==-1)return;` +
281+ `return _ce.apply(console,arguments)` +
282+ `}}` +
283+ `</script>` ,
284+ ) ;
285+
271286 // Add relay script tag to head
272287 const relayTag = this . getRelayScriptTag ( ) ;
273288 if ( relayTag ) {
You can’t perform that action at this time.
0 commit comments