-
-
Notifications
You must be signed in to change notification settings - Fork 349
Idea: make inject
a reactive function as well
#111
Comments
This would be a great feature as it allows you to make components that are not strictly bound to a mobx store as you will be able to feed the components with only the stuff it needs directly like one does in redux mapToProps/dispatchToProps. |
I think that it could be considered as a bug. This is really annoying to developer, when reactive library became non-reactive (does not trigger re-render on some cases). I think we should reduce that cases as much as possible. |
@ConneXNL / @Strate I think it would allow for things like:
But, then
Might just be more straight forward? On the other hand, it might be confusing for people, especially coming from Redux, that injecting like below doesn't work (changing the counterStore does not re-render Counter, because
(see: http://stackoverflow.com/questions/39128210/mobx-react-inject-and-observe-together) |
@ConneXNL you can try the reactive |
As discussed on gitter. The following problem occurs that incorrectly re-renders observable components: highlighted: expr(() => state.isHighlighted(item)) fixes the problem but shouldn't be required. |
Awesome to see this one getting into mobx! The above problem is fixed with #160 . However, the mobxjs/mobx-react-devtools does log 'inject-MyComponent#0.render()' to the console (if enabled) and all the elements highlight that are related to the injected property. As far as I know this wasn't the case before and is not intended? You can see this by using the https://gist.github.com/ConneXNL/32f65c708efb61af3e3e2d6f2df4aa4c example. |
@ConneXNL that is a result of making selectors reactive, if you pass a function into inject, it becomes an observer component as well, which is correct as you probably want to see that one reaction as well when needed(?) Might be changed indeed later, but at least not in the 4.0 release directly (there is an open todo / idea for that in the code) |
I can see that being the case with the console.logging + you are able to disable the logging yourself by applying a filter. However, I feel that for highlighting the elements it's not a good default to have them blink when the render() method of the component owning the element isn't hit. |
Shipped with 4.0.0 :) |
See this SO issue: http://stackoverflow.com/questions/39128210/mobx-react-inject-and-observe-together
This means that any props preprocessing done by
inject
could be tracked as well, if the generated injectWrapper component would be an observer itself as wellThe text was updated successfully, but these errors were encountered: