Closed rodgomesc closed 3 years ago
declare + comment in VisionCamera :
/**
* A native logging function (outputs to Xcode console/Android Logcat)
*/
declare var _log: (message: string) => void | undefined;
implementation from Reanimated:
auto callback = [](
jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *args,
size_t count
) -> jsi::Value {
const jsi::Value *value = &args[0];
if (value->isString()) {
Logger::log(value->getString(rt).utf8(rt).c_str());
} else if (value->isNumber()) {
Logger::log(value->getNumber());
} else if (value->isUndefined()) {
Logger::log("undefined");
} else {
Logger::log("unsupported value type");
}
return jsi::Value::undefined();
};
jsi::Value log = jsi::Function::createFromHostFunction(rt, jsi::PropNameID::forAscii(rt, "_log"), 1, callback);
rt.global().setProperty(rt, "_log", log);
This is outdated since VisionCamera supports console.log
since https://github.com/mrousavy/react-native-vision-camera/pull/297.
thanks, for the quick feedback
https://github.com/mrousavy/vision-camera-image-labeler/blob/cbf88a545e2aabcbc97aaf2717617ef1e0a69aa9/example/src/App.tsx#L25