react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Latest release delete precomputeStyle module?

Open jarvys opened this issue 11 years ago • 11 comments

redbox report 'unknown module precomputeStyle'

jarvys avatar Oct 29 '15 03:10 jarvys

+1 is there a replacement for precomputeStyle?

This used to work, but now doesn't:

var precomputeStyle = require('precomputeStyle');

screen shot 2015-10-28 at 9 28 36 pm

pickhardt avatar Oct 29 '15 04:10 pickhardt

Wondering the same thing over here

corymsmith avatar Oct 29 '15 17:10 corymsmith

Looks like this commit by @sebmarkbage https://github.com/facebook/react-native/commit/6244fd003de4eb6ce7fc7c40632948bf27cca201#diff-459f28dd7480110d5d268af6f1204452

It was a private module so technically we shouldn't have been using it :) Is there a good alternative to use in native modules?

corymsmith avatar Oct 29 '15 18:10 corymsmith

Yeah, I know it was private, but people were using it (even though technically maybe we shouldn't have) It was useful. Is there an alternative?

Maybe it should get made into a public class method of StyleSheet, like StyleSheet.precomputeStyle

pickhardt avatar Oct 29 '15 18:10 pickhardt

Why and how were you using it exactly?

It may product a result that may not be idempotent (in the mathematical sense). I.e. there may not be a public API that you can pass it to because it would be computed again.

sebmarkbage avatar Oct 29 '15 18:10 sebmarkbage

Here's an example that was using it:

https://github.com/brentvatne/react-native-scrollable-tab-view/commit/c111d7746a87b7cebe07e90e3d73eede4970df53#diff-c7ac8c6ffd293d4101dad4033eedd5f7

(The function setAnimationValue uses it.)

pickhardt avatar Oct 29 '15 18:10 pickhardt

I am facing same problem :) . I am also using react-native-scrollable-tab-view

shishircc avatar Oct 30 '15 09:10 shishircc

I think that was an invalid use of precomputeStyle. Perhaps due to a misunderstanding of the setNativeProps API. @brentvatne Could you clarify why it was needed since it was already doing that here?

https://github.com/facebook/react-native/blob/6f17dba39b447a540491ce7f8e6256a59ea2d4c5/Libraries/ReactIOS/NativeMethodsMixin.js#L80

And is still doing it. What breaks if you just remove the call?

sebmarkbage avatar Oct 30 '15 16:10 sebmarkbage

It also broke this popular scroll refresher component https://github.com/syrusakbary/react-native-refresher/issues/14

ghost avatar Nov 07 '15 21:11 ghost

+1

urquilla avatar Dec 03 '15 21:12 urquilla

Sorry I just saw this -- I believe the reason why I did this is very silly, you guessed it @sebmarkbage.

I didn't realize at the time that I should have used the style key for style props: setNativeProps({style: {transform: [...etc]}}).

This is probably because setNativeProps let me get away with directly passing in style properties like setNativeProps({left: 5}) for everything except transform. Of course now it is obvious to me why -- setNativeProps ran precomputeStyle on the style object passed in, which then precomputed the transform matrix. :stuck_out_tongue:

So yeah, precomputeStyle isn't needed anymore.

brentvatne avatar Dec 13 '15 03:12 brentvatne