-
-
Notifications
You must be signed in to change notification settings - Fork 351
@observer(['store props']) not available to react-dnd #77
Comments
@jamiewinder would you mind attaching a minimal example which reproduces the problem? |
@jtraub - Here you are: http://codepen.io/jamiewinder/pen/PzKPko?editors=1010 As you can see on the rendered component, the appState is reaching the component during rendering (as are the normal props). However, if you begin dragging the text, you'll get an alert ('appState is undefined, ticks is x') showing that the If you swap the decorators around on |
@jamiewinder http://jsbin.com/yayuzedusi/edit?js,output Add another observer on top or use something else ( You can even pass stores manually |
Note: I do not have react-dnd experience at all. As far as I understood This component receives only |
Thanks, I just stumbled on the same workaround! I think you're probably right in your guess at what the cause is, but I'm not sure what needs to be done about it. I go with the workaround for now. |
It is expected HOC behavior and it is documented in
In your case decorated component is I would recommend you to install React Developer Tools and see an actual component hierarchy in your example to better understand how several decorators are applied to a component. |
It might be expected, but applying the same decorator twice is a bit strange. It feels a bit like @provide(['appState'])
@dragSource
@observer class MyComponent {
} That said, I'm not sure there are many other situations where you'd want to What do you think @mweststrate ? |
Technically it is quite easy to provide a separate decorator Mobx-react already has such function which is used internally. Given, that all you need to do is to slightly modify and export this function under an appropriate name, It would be great to have this feature. |
@jtraub yes I think you are right. I think we should export a separate |
See also: #70 |
Just released 3.5.0, which separates @inject('appState')
@DragSource('item', dragSourceSpec, dragSourceCollect)
@observer
class // ... erc |
I had posted this as a comment in #64 , but I think it may be an issue in its own right rather than a question of usage.
When using
@observer([stores])
with react-dnd, the injected props aren't available to the react-dnd functions.Swapping the decorators around fixes this, but causes
@observer
to have no effect other than the props injection.Let me know if any more details are needed.
The text was updated successfully, but these errors were encountered: