Open bhupinderbola opened 5 years ago
Can you please explain why this is unexpected? Observables are a form of dynamic styles.
As per the documentation (https://cssinjs.org/js-api?v=v9.8.7#extract-dynamic-styles ),
Extracts a styles object with only props that contain function values
. Also it creates issue with react-jss. React-jss calls sheet.update on dynamic styles. But observables do not have any data to update.
Or we should fix the problem in react-jss by adding a check for fn values
Yeah, we should fix the docs and fix react-jss by adding a check.
Is there a use case for observables inside react-jss currently?
Same use case as with core, being able to stream the values from thee outside, for e.g. a complex animation using rx utils
But this would break as soon as you render two different instances of the same component. You would need to create a new HOC for every rendered component.
Why would it break? We don't reuse dynamic style between elements.
Yeah, but the observable would be the same. You can only have an animation which is shared between all components
ToDos for this:
getDynamicStyles
True that. I wonder if we should support a fn value that returns an observable.
Alternatively separate components per animation might be also acceptable.
Please no. This would just create more confusion. We would also need a way to pass the observable then back to the user.
We should definitely document the problem with observables and react-jss somewhere.
yeah, the user would have to manage observable instances.
Probably for now user could just create separate components for each animation and scope the observable in his HOC creator function.
I think for most users function values should be enough.
Totally, but then we have this Observables feature and it would be evtl nice to be able to use it with react-jss together. I don't know how to decide on whether it should be supported or not, I think if its not hard and does't causes additional bugs, we could. That thing per component can be solved in user space ... I guess your concern comes from implicitness of this behaviour one wouldn't expect?
Yeah, exactly.
On the other side it would be confusing not having support for observables in react-jss because it claims to support the same syntax, and Observables are part of it.
Expected behavior: Observable rules should not be included in the getDynamicStyles()
Describe the bug: Observable rules are included in the results of getDynamicStyles()
Codesandbox link: https://codesandbox.io/s/xrmo482nr4
Versions (please complete the following information):