Guarantee ViewGraph only passes numbers to charts

This error occurs on some devices in the Play store
(android 12). I can't reproduce it unless I forcefully
pass NaN to my charts, so this might just fix the error.
Related to #206.

Exception java.lang.Error:
  at com.horcrux.svg.PathParser.parse_number (PathParser.java:627)
  at com.horcrux.svg.PathParser.parse_list_number (PathParser.java:594)
  at com.horcrux.svg.PathParser.parse (PathParser.java:118)
  at com.horcrux.svg.PathView.setD (PathView.java:28)
  at com.horcrux.svg.RenderableViewManager$PathViewManager.setD (RenderableViewManager.java:751)
  at com.horcrux.svg.RenderableViewManager$PathViewManager.setD (RenderableViewManager.java:740)
  at com.facebook.react.viewmanagers.RNSVGPathManagerDelegate.setProperty (RNSVGPathManagerDelegate.java:112)
  at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps (ViewManagerPropertyUpdater.java:46)
  at com.facebook.react.uimanager.ViewManager.updateProperties (ViewManager.java:84)
  at com.facebook.react.uimanager.ViewManager.createViewInstance (ViewManager.java:188)
  at com.facebook.react.uimanager.ViewManager.createView (ViewManager.java:115)
  at com.facebook.react.uimanager.NativeViewHierarchyManager.createView (NativeViewHierarchyManager.java:281)
  at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute (UIViewOperationQueue.java:194)
  at com.facebook.react.uimanager.UIViewOperationQueue$1.run (UIViewOperationQueue.java:909)
  at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches (UIViewOperationQueue.java:1026)
  at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded (UIViewOperationQueue.java:1086)
  at com.facebook.react.uimanager.GuardedFrameCallback.doFrame (GuardedFrameCallback.java:29)
  at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame (ReactChoreographer.java:175)
  at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame (ChoreographerCompat.java:85)
  at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1106)
  at android.view.Choreographer.doCallbacks (Choreographer.java:866)
  at android.view.Choreographer.doFrame (Choreographer.java:792)
  at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1092)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at android.app.ActivityThread.main (ActivityThread.java:8751)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:571)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1135)
This commit is contained in:
Brandon Presley 2024-02-09 11:27:03 +13:00
parent f8a4157c33
commit 1921ecb9f4
1 changed files with 5 additions and 3 deletions

View File

@ -26,9 +26,11 @@ export default function ViewGraph() {
const [unit, setUnit] = useState('kg');
const convertWeight = (weight: number, unitFrom: string, unitTo: string) => {
if (unitFrom === unitTo) return weight;
if (unitFrom === 'lb' && unitTo === 'kg') return weight * 0.453592;
if (unitFrom === 'kg' && unitTo === 'lb') return weight * 2.20462;
let result = weight;
if (unitFrom === unitTo) result = weight;
if (unitFrom === 'lb' && unitTo === 'kg') result = weight * 0.453592;
if (unitFrom === 'kg' && unitTo === 'lb') result = weight * 2.20462;
return isNaN(result) ? 0 : result;
};
useEffect(() => {