-
Notifications
You must be signed in to change notification settings - Fork 759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose the React mounting and un-mounting mechanisms #117
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
👍 I know there are some other PRs out there regarding turbolinks compatibility and events but this seems like a solid improvement on master. I see you added a bit about removing |
Those My question would be: Do we want to keep 2 different |
seems right to replace the previous one with this one, right? It's the same code (with that bit added), just assigned to |
Sounds good to me. I'll delete the need to do some paying work first, so e.t.a on that tonight sometime |
Replaced the primary |
Added tests to the view_helper that looks for the presence of all the exported methods and attributes. All green. |
👍 |
|
||
// rather than create another namespace just for the 3 methods and 2 | ||
// properties we expose just append them to the `React.ujs` object | ||
React.ujs = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I'd rather we didn't add things to React.*
at this point as the functionality provided here is distinct from the rest of React and could lead to confusion/problems down the line (it's unlikely in this case but there are other properties we may want to add to React without potential issues).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair, but raises another question: Where then? I have no strong feelings about where, just that they need to be exposed somewhere. Ideas?
Reason I put them there, risking stating the obvious, is that you are using React + Rails. So the appended namespace is not a surprise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about a global like ReactRailsUJS
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll put in whatever consensus wants. Is there a precedent with any other UJS
things?
@zpao I think we're just waiting on your OK or other suggestion on these 2 questions. It would be nice to get this worked out, then update those other PRs |
Yep, I can proceed as follows (just want the consensus first, so as not to do it again):
I think thats it? |
@zpao any objections to going forward like that ^^ ? @robrobbins He said he'd be busy so if we don't hear from him in 48 hours, I think we should take that as agreement :) |
sure. i'll get on it later today then |
👍 sounds good! Sorry for the delay, this project is unfortunately low on the priority list with everything else :( |
Done |
👍 you're a good man @robrobbins dropped this in locally just to make double-sure & looks good to me |
👍 Thanks Did the same, been using it on the redesign of a big commercial app. Doing fine. |
💸 |
Expose the React mounting and un-mounting mechanisms
This is a great addition. Quick question, is there any reason to leave the JSON inside of the data-react-props attribute after you've called React.render()? My current application renders about 5000 objects to the page, and having those sit in the attribute causes the developer console to crawl and sometimes crash. My current approach is just to call node.removeAttribute(PROPS_ATTR) right after the render step in the MountComponents function. Is there a reason to keep that attribute around? |
@jmagoon I'd be in favor of that change. The only downside I can think of is that components wouldn't be re-mountable. But, is that something that matters? Does anyone depend on that? Actually, I think I do that sometimes: arbitrarily fire Oh wait, that wouldn't work because Anyways, I'm open to something like that ^^, especially if we could get something like #91 worked in. (Then I could stop my stupid hack for mounting new components!) |
Re: #116
This is my initial commit, all within a
react_ujs_p.js
file so that we may discuss it further. I'll get to the tests tomorrow, though I expect the existing to pass. I do need to write a few new ones.Currently I am using this modded version is a non-turbolinks SPA and it works fine.