Closed ieugen closed 9 years ago
@ieugen @overrideModel
isn't called when the query parameter changes? I'll take a good look at this when I find sometime. Meanwhile I'm interested in understanding if the route change with the same path is a bug in backbone react component.
Yes, that is the issue. But a more broader thing would be not to depend on the mixin. That way, it could be used also with ES6 classes that do not support mixins.
Let me know what you find. It might be a bug in react-router also. But not that probable.
Regards,
2015-03-19 10:14 GMT+01:00 José Magalhães notifications@github.com:
@ieugen https://github.com/ieugen @overrideModel isn't called when the query parameter changes? I'll take a good look at this when I find sometime. Meanwhile I'm interested in understanding if the route change with the same path is a bug in backbone react component.
— Reply to this email directly or view it on GitHub https://github.com/magalhas/backbone-react-component/issues/65#issuecomment-83433191 .
Ioan Eugen Stan 0720 898 747
Regarding a way of using the lib programatically, feel free to suggest an interface, I'll consider implementing it.
@ieugen can you provide me a (not) working example of that problem? I mean, the query part changing and props being deleted? I would like to debug that scenario.
@ieugen just implemented on
and off
methods to achieve this. How does it work? You can check the unit tests but the API is this:
componentDidMount: function () {
require('backbone-react-component').on(this, myBackboneCollectionsOrModels);
},
componentWillUnmount: function () {
require('backbone-react-component').off(this);
}
The API looks nice. I hope I get some time to test it. I've been off React for some time now.
It's released.
Hello Jose,
I found an issue with react-backbone-component and react-router that made me think about looking for alternatives like RefluxJS and ditch the backbone stuff (I had a lot of bad experiences with Backbone in the past. They still come and haunt me :( ).
The problem is that the mixin does not get called when react-router changes the route, and the new route has the same path, but a different query param. The
this.props.model
is erased and the code breaks.Reading the RefluxJs documentation on how to integrate with React [1] I found out that you can design backbone-react-component to be called programatically during the component life-cycles, and not as a mixin. That way, I can make sure that the integration works and I have full control. The mixin could be added as a convenience, similar to RefluxJs case, giving developers more freedom and more control.
I provided a gist showing my React view. Notice I build next and prevvious links by suppling query params. First rendering works, going for next/previous fails.
How hard would it be to do this in the current state of the project?
[1] https://github.com/spoike/refluxjs#react-component-example [2] https://gist.github.com/ieugen/ca17c3463d26eddc07d5