mobx-state-tree icon indicating copy to clipboard operation
mobx-state-tree copied to clipboard

Hide warnings

Open olehreznichenko opened this issue 7 years ago • 10 comments

I have:

  • [x] Feature request
  • [x] I've checked documentation and searched for existing issues

Lets add in to configuration some prop for hide warnings such this

[mobx-state-tree] Warning: Attaching onAction listeners to non root nodes is dangerous: No events will be emitted for actions initiated higher up in the tree.

like did styled-components https://github.com/styled-components/styled-components/commit/86fac6af698b62965c2649a30d81e46d92c7373e With hmr i have a lot of warnings

olehreznichenko avatar Oct 17 '18 18:10 olehreznichenko

Could you share an example of the logs you get when using HMR?

xaviergonz avatar Oct 17 '18 19:10 xaviergonz

The example in the description of propose, have only onAction warnings

olehreznichenko avatar Oct 17 '18 19:10 olehreznichenko

but like, do you get one warning after each hot reload? 100? is it always for the same node? for different ones?

xaviergonz avatar Oct 17 '18 19:10 xaviergonz

My point is that maybe there could be a cache of warnings that keep track of what warning for what node has been issued to not do it twice

xaviergonz avatar Oct 17 '18 19:10 xaviergonz

Sure, I made two onAction listeners when store is attached, and after each hmr see in the console again this two warnings. Same nodes.

olehreznichenko avatar Oct 17 '18 19:10 olehreznichenko

Maybe cache is better

olehreznichenko avatar Oct 17 '18 19:10 olehreznichenko

Why is a warning needed in this case in the first place? It seems obvious to me that an onAction listener will only emit for the subtree it's attached to.

rbuels avatar Sep 11 '19 18:09 rbuels

I agree with @rbuels, this warning doesn't really makes sense, since I am aware that it will be applied to to subtree where I am using it. Why is it dangerous in this case?

beepsoft avatar Feb 04 '22 08:02 beepsoft

any solution for this ? is there a alternate way to listen to subtree ?

Gowtham2003 avatar Jun 12 '22 12:06 Gowtham2003

This is also something we would like to disable when it is purposely implemented

s-pace avatar Nov 09 '22 10:11 s-pace