Hi, first of all, thanks for the great work.
I'm trying to use the concat function to animate a text using ReText component from react-native-redash,
but look like the concat function always add ".0" to the end of the animated number node on Android .
My Code
const price = new Value(44);
const MyString = concat('$', price);
MyString should be $44
IOS : $44
Android : $44.0
Note: The problem is Not related to Retext Component, I tried passing the MyString value to the javascript side using call function and noticed the same behavior.
I think this is related to this issue in react-native. Since there is still only Number in ReadableType, one can't tell react-native to return the string representation of an integer.
I did manage to fix the issue by updating the evaluate method in ConcatNode implementation on Android
https://github.com/software-mansion/react-native-reanimated/blob/master/android/src/main/java/com/swmansion/reanimated/nodes/ConcatNode.java#L15
@Override
protected String evaluate() {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < mInputIDs.length; i++) {
Node inputNodes = mNodesManager.findNodeById(mInputIDs[i], Node.class);
String a = String.valueOf(inputNodes.value());
if(a.endsWith(".0")) {
a = a.substring(0, a.length() - 2);
}
builder.append(a);
}
return builder.toString();
}
I know is not the best solution but At least it fixed my issue 馃榿.
Glad you found a workaround, don't think it's bad at all, given the limitations :)
@osdnk, @kmagiera Do you think my Solution deserve a PR, Any feedBack
Hi @yjose,
thanks for submitting this issue!
I confirmed it's reproducible.
Your workaround could be improved by using Double values directly, I'll prepare PR for this one.
Thanks, @yjose @jakub-gonet, I just tried your PR and it works great!
Most helpful comment
Hi @yjose,
thanks for submitting this issue!
I confirmed it's reproducible.
Your workaround could be improved by using Double values directly, I'll prepare PR for this one.