Skip to content

Conversation

Szymon20000
Copy link
Contributor

Description

Fixes: #1758
Currently, when we send callback function to UI thread and then back to RN then we will get function wrapper that checks is somebody uses runOnJS. In order to solve the problem, I've added logic that attaches additional info to a function wrapper that allows to get original callback.

Changes

Test code and steps to reproduce

Checklist

  • Included code example that can be used to test this change
  • Updated TS types
  • Added TS types tests
  • Added unit / integration tests
  • Updated documentation
  • Ensured that CI passes

@Szymon20000 Szymon20000 requested a review from piaskowyk March 18, 2021 07:15
@@ -239,8 +250,10 @@ jsi::Value ShareableValue::toJSValue(jsi::Runtime &rt) {
}
case ValueType::HostFunctionType: {
auto hostFunctionWrapper = ValueWrapper::asHostFunctionWrapper(valueContainer);
if (hostFunctionWrapper->hostRuntime == &rt) {
auto hostRuntime = hostFunctionWrapper->value->hostRuntime;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use here auto & instead of auto to avoid unnecessary copying of objects.

@Szymon20000 Szymon20000 merged commit f8f2805 into master Mar 18, 2021
@Szymon20000 Szymon20000 deleted the @szymon/fix_host_function branch March 18, 2021 09:38
@enesozturk
Copy link
Contributor

enesozturk commented Mar 18, 2021

You made my day 🔥 Looking forward to examples and new release 🤩

@piaskowyk piaskowyk mentioned this pull request Mar 22, 2021
1 task
piaskowyk added a commit that referenced this pull request Mar 23, 2021
## Description

Method `std::shared_ptr<jsi::Function> get()` from `struct HostFunctionHandler : jsi::HostObject` had name conflict wtih `virtual Value get(Runtime&, const PropNameID& name)` from `jsi::HostObject` and this crashed CI and compilation for android.
Related with: #1844

## Checklist

- [x] Ensured that CI passes
@enesozturk
Copy link
Contributor

Hi, is this pr included in v2.0.1? Looks like the problem is still continue.

@enesozturk
Copy link
Contributor

Hi, I am following issue for my package. It is solved with v2.1.0 actually. When I try it on Expo project with same version (v2.1.0), problem still exist. Not sure if I open an issue in Expo. Wanted to let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Value is undefined, expected an Object
3 participants