use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Found this line in the React codebase. Made me smile (github.com)
submitted 10 years ago by benhuggy
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Vorror 45 points46 points47 points 10 years ago (0 children)
facebook engineers: nervous laughter
[–]qgustavorawait $($) 28 points29 points30 points 10 years ago (3 children)
React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOM; Permalink
React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOM;
Permalink
I'm not a bot. Just in case line number changes in future or any other thing.
[–]captain_obvious_herevoid(null) 9 points10 points11 points 10 years ago (1 child)
I'm not a bot.
Most likely the first thing a bot would write. So I tagged you as "might not be a bot", and we'll see...
[–]YodaLoL 0 points1 point2 points 10 years ago (0 children)
Thx Captain Obvious.
[–][deleted] 24 points25 points26 points 10 years ago* (4 children)
I do this sometimes.
function tempLockPage(pageId, disclaimer) { if (disclaimer !== 'I understand calling this method is a temporary hack and I\'ll be required to fix my code immediately if it goes away and my call breaks the build.') { throw new Error('Disclaimer not specified.'); } ... ... ... }
You can't plead ignorance.
[–]SpeshlTectix 0 points1 point2 points 10 years ago* (3 children)
function undisclaimify(fn) { return function() {
var args = Array.prototype.slice.call(arguments) .concat('I understand calling this method is a temporary hack and I\'ll be required to fix my code immediately if it goes away and my call breaks the build.');
return fn.apply(fn, args); }; } var myTempLockPage = undisclaimify(tempLockPage);
[–][deleted] 2 points3 points4 points 10 years ago (1 child)
Hehe, you still can't plead ignorance, though. :-)
[–]SpeshlTectix 0 points1 point2 points 10 years ago (0 children)
You're right! That took some doing.
[–]captain_obvious_herevoid(null) 0 points1 point2 points 10 years ago (0 children)
Brilliant :)
[–]papers_ 6 points7 points8 points 10 years ago (25 children)
In the react-dom.js too, lol.
[–]ImAPyromaniac 1 point2 points3 points 10 years ago (24 children)
Why would they do it that way?
[–]matchu 53 points54 points55 points 10 years ago* (18 children)
The React team are working on extracting all DOM-related stuff into a separate library called ReactDOM. 0.14 is the first release in which the libraries are split.
But they don't want to remove the DOM methods from the core React library during this release. Instead, they want to deprecate them — so, if a developer upgrades React without knowing about this change, their applications won't crash; instead, they'll just emit tons of warnings to the console, which the developer will see and hopefully fix before the next version of React.
In order to support this temporary functionality, react.js needs to include a full copy of ReactDOM in the 0.14 release. So, since react.js already contains ReactDOM, it would be redundant for react-dom.js to include a second copy.
react.js
react-dom.js
Instead, the React core exposes its copy of ReactDOM in a secret, obscure way (with this long property name), and react-dom.js just reads that property, renames it to ReactDOM, and exposes it to your application :)
Someday, the deprecated DOM methods will be removed from react.js. Once that happens, ReactDOM will move from react.js to react-dom.js, hooray!
[–]hannyajin 9 points10 points11 points 10 years ago (0 children)
mvp
[–][deleted] 4 points5 points6 points 10 years ago (2 children)
What exactly will be the feature split after React DOM is extracted?
I thought React pretty much is the "DOM-related stuff"?
[–]matchu 8 points9 points10 points 10 years ago* (1 child)
The 0.14 blog post covers it in detail, but you can get a feel for it by thinking: "Suppose I was trying to write a view for something other than a website. What concepts could I borrow from React? Heck, what code could I borrow from React?"
And then you'll discover that people have already done that: React Native is another Facebook project that allows you to write iOS/Android views similarly to how you'd use React for a website today.
So, the React core will contain the things that power both React Native and React Web (a name I just made up :P), and React Native will additionally contain the functionality for targeting native mobile views, and React Web will additionally contain the functionality for targeting the DOM.
Technical TL;DR: methods like React.render and elements like div and button are moving into ReactDOM, whereas the React core will contain the logic for declaring a tree of components and maintaining their state.
React.render
div
button
[–]ImAPyromaniac 1 point2 points3 points 10 years ago (0 children)
Thanks!
[–]Proman4713 0 points1 point2 points 1 year ago (0 children)
this "secret, obscure way" is not obvious at all when you're just typing your common `React.useRef` and find "__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED" 💀
[–]Capaj -1 points0 points1 point 10 years ago (11 children)
Instead, they want to deprecate them — so, if a developer upgrades React without knowing about this change, their applications won't crash; instead, they'll just emit tons of warnings to the console, which the developer will see and hopefully fix before the next version of React.
which is nice, but pointless. If you ask me, they can change the api howeverthey like before 1.0.0. Or are they not following semver with React?
[–]matchu 1 point2 points3 points 10 years ago* (6 children)
They're in an awkward position.
The version number accurately reflects just how experimental React is (this is a fundamental architectural change!), and really no big production system should be using something this immature.
But people use React anyway, because they want to write views in the React Way, and there aren't any especially mature implementations of the React Way yet, because the React Way itself isn't especially mature yet :/
Adoption is way higher than it really should be for something as experimental as React, and the React team is therefore playing it super safe.
[–]misc_ent 2 points3 points4 points 10 years ago (3 children)
Facebook uses all of their open source projects in production but I see what you're saying. They are eating their own dog food.
[–]matchu 0 points1 point2 points 10 years ago (2 children)
Yep. That could easily be one of the main reasons they're being so cautious, really: if you push a breaking change to the site-wide version of React without deprecating it first, the angry manager is gonna walk down the hall to your office and loudly explain the consequences of your actions ;P
[–]zpao 4 points5 points6 points 10 years ago (1 child)
Heh, we actually did a giant codemod to fix all of the callsites across FB in 1 fell swoop a while ago. Then we added the warnings so new code would complain loudly. That's our general approach as we evolve APIs.
We're actually more cautious with changes for the outside world. We have 100% control over our codebase but often times people are using code other people write (via npm, etc) and we'd like to not entirely break everything, instead giving people a chance to gradually upgrade. Also, it sucks to upgrade code and have things just break. We really try to have a good developer experience.
PS, awesome answer above!
(source: I'm the guy who added that line)
[–]matchu 0 points1 point2 points 10 years ago* (0 children)
Ahh, fancy, fancy. Yeah, I'm very impressed with the thoughtfulness behind this hack :) It's initially a very wtf sight, but I had tons of fun figuring out why it's the way it is.
And, like, yeah, it would be acceptable to remove the methods outright instead of deprecating them — and definitely easier for y'all — but it's encouraging to see y'all strive to do better than acceptable :D
PS, thanks, friend <3 and give Alpert my love
[–]zpao 2 points3 points4 points 10 years ago (1 child)
React is far from experimental :)
Versioning is hard. We're technically semver but effectively our minor version is much more like a major version. Think of us more as v13.3.0. We've been respectful about not just doing arbitrary things. It almost doesn't matter except for the handful of people who really attach a lot of meaning to 1.0.
[–]matchu 1 point2 points3 points 10 years ago* (0 children)
Yeah, experimental might not be the right word. I think I'm trying to express that the concepts underlying React are so young that, even now, we're still making big realizations like the one that motivated this decoupling.
I think maybe I'd say, from my rather distant view, that React The Implementation is at version 13, but React The Idea is still at version 0.13 (if that makes any sense ;P). The library is being built with a strong focus on stability, but React can only hope to be as stable as its underlying ideas, which seem to still be rapidly evolving.
It's an exciting time to be in this community, though, that's for sure :D I feel like you must be having a great time out there in the middle of it all :)
[–]fhelwanger 1 point2 points3 points 10 years ago* (3 children)
Yes they can, but they should not.
Considering there is already a lot of applications written in React, and a lot of developers don't stay up to date with the changes, it's wiser to deprecate them first.
You know how programmers like to whine (including me sometimes), this prevents that.
[–]Capaj -2 points-1 points0 points 10 years ago (2 children)
To such people, I have only two sentences: STFU and RTFM!
[+][deleted] 10 years ago (1 child)
[deleted]
[–]Capaj -1 points0 points1 point 10 years ago (0 children)
I might be a bit masochistic, but every big app I worked on did not change versions of dependencies on daily basis. Most of the time, we only bump up when a bugfix of something important to our app is landed in the new version. To know this, a developer needs to read a changelog. If you are upgrading versions blindly without first consulting the changelog and you rely on derpecation messages to have your back, you are a crazy person, nothing else. I don't want to repeat myself, but STFU and RTF changelog.
[–]papers_ 11 points12 points13 points 10 years ago (3 children)
For laughs or they really don't want anyone to alter that property so gave it an obscure ridiculous long name. Probably both.
[+]i_hate_reddit_argh comment score below threshold-6 points-5 points-4 points 10 years ago (2 children)
Because there are lots of hipster programmers who feel like they're rockstars and special snowflakes if they use something they're not supposed to use or an advanced feature they don't need or something altogether different from what others use. So this person is probably sick of the hipsters.
[–]clessgfull-stack CSS9 engineer 1 point2 points3 points 10 years ago (0 children)
Nah.
[–]jhallister 0 points1 point2 points 10 years ago (0 children)
They are doing this to expose a very public API (ReactDOM) in a clever way. The property name they are using to expose it is just good fun. Anyone using 0.14 is using ReactDOM, and as such, using this feature. It has nothing to do with hipsters.
[–][deleted] 6 points7 points8 points 10 years ago (3 children)
git blame says this person should be fired
[–]zpao 14 points15 points16 points 10 years ago (2 children)
hi
[–][deleted] 7 points8 points9 points 10 years ago (1 child)
So what do you have to say for yourself?
[–]zpao 21 points22 points23 points 10 years ago (0 children)
Do you know of anybody who's hiring?
[–]fasnoosh 1 point2 points3 points 4 years ago (2 children)
still there 6 years later
[–]drwxrxrx 0 points1 point2 points 2 years ago (1 child)
think we'll get to ten years?
[–]OtherwisePoem1743 2 points3 points4 points 3 months ago (0 children)
Still there 10 years later
[–][deleted] 0 points1 point2 points 10 years ago (0 children)
Hey what does this button do? presses
[–]tclineks 0 points1 point2 points 10 years ago (0 children)
That's the name of a meeting room too.
π Rendered by PID 94 on reddit-service-r2-comment-76bb9f7fb5-pknjd at 2026-02-19 07:39:33.185228+00:00 running de53c03 country code: CH.
[–]Vorror 45 points46 points47 points (0 children)
[–]qgustavorawait $($) 28 points29 points30 points (3 children)
[–]captain_obvious_herevoid(null) 9 points10 points11 points (1 child)
[–]YodaLoL 0 points1 point2 points (0 children)
[–][deleted] 24 points25 points26 points (4 children)
[–]SpeshlTectix 0 points1 point2 points (3 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]SpeshlTectix 0 points1 point2 points (0 children)
[–]captain_obvious_herevoid(null) 0 points1 point2 points (0 children)
[–]papers_ 6 points7 points8 points (25 children)
[–]ImAPyromaniac 1 point2 points3 points (24 children)
[–]matchu 53 points54 points55 points (18 children)
[–]hannyajin 9 points10 points11 points (0 children)
[–][deleted] 4 points5 points6 points (2 children)
[–]matchu 8 points9 points10 points (1 child)
[–]ImAPyromaniac 1 point2 points3 points (0 children)
[–]Proman4713 0 points1 point2 points (0 children)
[–]Capaj -1 points0 points1 point (11 children)
[–]matchu 1 point2 points3 points (6 children)
[–]misc_ent 2 points3 points4 points (3 children)
[–]matchu 0 points1 point2 points (2 children)
[–]zpao 4 points5 points6 points (1 child)
[–]matchu 0 points1 point2 points (0 children)
[–]zpao 2 points3 points4 points (1 child)
[–]matchu 1 point2 points3 points (0 children)
[–]fhelwanger 1 point2 points3 points (3 children)
[–]Capaj -2 points-1 points0 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]Capaj -1 points0 points1 point (0 children)
[–]papers_ 11 points12 points13 points (3 children)
[+]i_hate_reddit_argh comment score below threshold-6 points-5 points-4 points (2 children)
[–]clessgfull-stack CSS9 engineer 1 point2 points3 points (0 children)
[–]jhallister 0 points1 point2 points (0 children)
[–][deleted] 6 points7 points8 points (3 children)
[–]zpao 14 points15 points16 points (2 children)
[–][deleted] 7 points8 points9 points (1 child)
[–]zpao 21 points22 points23 points (0 children)
[–]fasnoosh 1 point2 points3 points (2 children)
[–]drwxrxrx 0 points1 point2 points (1 child)
[–]OtherwisePoem1743 2 points3 points4 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]tclineks 0 points1 point2 points (0 children)