Re:“Implement text editor DOM updates manually instead of vi...
by polskibus on Friday February 27, 2015 @03:05AM
(#9117748)
You can download react tools for chrome and check react usage by just launching developer tools.
Re:“Implement text editor DOM updates manually instead of vi...
by bsummer4 on Friday February 27, 2015 @02:54AM
(#9117712)
Thanks! That's really cool.
Re:“Implement text editor DOM updates manually instead of vi...
by PSeitz on Friday February 27, 2015 @04:01AM
(#9117895)
That killed my facebook tab
Re:“Implement text editor DOM updates manually instead of vi...
by runeks on Friday February 27, 2015 @08:26AM
(#9118672)
function() { Array.prototype.slice.call(document.querySelectorAll('[data-reactid]')).forEach(function(element) { element.style.background = 'rgba(255,0,0,0.1)'; }) }
is executed every 500 ms using command in question. So if the above function takes 500 ms or more to execute, the tab will get stuck (I would think).Try just executing this command once:
Array.prototype.slice.call(document.querySelectorAll('[data-reactid]')).forEach(function(element) { element.style.background = 'rgba(255,0,0,0.1)'; })
Re:“Implement text editor DOM updates manually instead of vi...
by dcherman on Friday February 27, 2015 @02:58PM
(#9120951)
Instead of using a timer or a one time selector, just add a new CSS rule via a style tag
(function() { var style = document.createElement( "style" );
style.innerHTML = "[data-reactid] { background: rgba(255,0,0,0.1); }";
document.head.appendChild( style );
}());
Re:“Implement text editor DOM updates manually instead of vi...
by PSeitz on Friday February 27, 2015 @09:29AM
(#9118968)
Yes, the attribute selector could be slow and/or the non-opaque drawing, I guess.
Re:“Implement text editor DOM updates manually instead of vi...
by zghst on Friday February 27, 2015 @02:51AM
(#9117708)
Fake test. React Components don't always return a DOM element, also not every element shows up all the time, instead you should download the React dev tools.
There are at least 30-40 top level components on Facebook. Nice try though.
Re:“Implement text editor DOM updates manually instead of vi...
by e1g on Friday February 27, 2015 @03:30AM
(#9117811)
You are of course correct that some React components will not be caught by this single-line test. It is impossible to truly know unless you are the author of the app, and that's the case even with React tools (e.g. you would not be able to identify my server-rendered components that are not mounted on the front-end).
The intent was not to provide a debugging tool - it's just to provide people with limited exposure to React a simple one-liner to help them understand what is meant when someone says Facebook/Instagram use React, and see some components in the wild. To that goal, using a simple test for data-reactid attribute will catch the overwhelming majority of in-the-wild use cases.
edit: the snippet is from Pete Hunt who is on the core React team (https://twitter.com/floydophone/status/557348616080076800)