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

use lodash.js isEmpty , throw error: Value type not supported.

Open HEYURAN opened this issue 1 year ago • 2 comments

import { Worklets } from 'react-native-worklets-core';
import _ from 'lodash';

const dataStr = '{"test-1":"123"}';

const context = Worklets .defaultContext;

const res = await context.runAsync(()=>{
    'worklet'
    return JSON.parse(dataStr);
});

const testData = JSON.parse(dataStr);

_.isEmpty(testData) // sucess 

try{
_.isEmpty(res) // throw error:  Value type not supported.
}catch(e){
}

HEYURAN avatar Apr 26 '24 07:04 HEYURAN

Not sure if I understand the difference between the two lines trying to call _.isEmpty(res) - they look the same to me except that the last one has a try..catch around it.

PS. I updated the code formatting a bit.

Could you try to explain a bit more in the description field?

chrfalch avatar Apr 26 '24 08:04 chrfalch

Not sure if I understand the difference between the two lines trying to call _.isEmpty(res) - they look the same to me except that the last one has a try..catch around it.

PS. I updated the code formatting a bit.

Could you try to explain a bit more in the description field?

sorry , The code has been updated to address the above issue. One more problem: when executing runAsync, the method contains buffer , throw : array buffer is not supported as a shared value

HEYURAN avatar Apr 28 '24 03:04 HEYURAN

I just added a test that verifies that JSON.parse returned from a worklet returns a correct JS object (and tested that _.isEmpty is working correctly). So I think this ticket is no longer valid / fixed already.

hannojg avatar Jun 03 '24 08:06 hannojg