-
Notifications
You must be signed in to change notification settings - Fork 430
POC: createElement patch + prototype methods patch #125
Conversation
@gaearon have you had any chance to look at this? |
Nope, no chance yet.
|
Can you remind me why we’re patching manually rather than via |
Not sure if I should post this here; I've tried to manually copy your code into my fresh new project that uses redux and react-router. And I get this error on the browser console when I modify any file:
Maybe it's related to your point:
since I'm using the Router I mean, or it's not, do you have any clue why this happens? |
@pepjo I'd really recommend not using this anywhere, it hasn't been tested at all. But it sounds like maybe your root component is not a class component |
@gaearon we're patching manually because we had this idea that just replacing the methods on the prototype would be enough (and would be simpler than going through |
@nfcampos It's just a project I'm messing with, nothing serious :P
I'm guessing thats what you ment when you said that createElement was messing with react router. Anyway, thanks for this (y) |
@pepjo yeah this still only works for really simple toy setups, eventually it might come to work in real apps |
I forgot about overriding bind(), my bad. |
Hey, thanks for your work. I played with this for a while but ultimately I went with |
Thanks for looking at it. I've started to play around with RHL 3 and I've left an issue here gaearon/react-hot-loader#240 |
open questions that i can think of:
still have to test whether this works for components wrapped in a HOCit appears to workReact.createElement
doesn't play well with code like this https://github.com/reactjs/react-router/blob/master/modules/RouterContext.js#L29 (unless there's some foolproof way of ensuring the patch happens before any line like that is ran) Making it work with react router currently requires providing the createElement prop like this<Router history={browserHistory} createElement={React.createElement}>
(and that still doesn't work if route components are not classes, which I think is related to the issue below)forceUpdate
it after hot reloading, since I can't get a ref to itnotes:
React.createClass()
but they shouldn't be any differentReact.createElement()