Skip to content

Commit 237ee2d

Browse files
philikonfacebook-github-bot
authored andcommitted
Fix Android startup exception
Summary: This is an attempt to fix the following startup exception that I get when running any of the example apps: > Unrecognized type: interface com.facebook.react.bridge.Dynamic for method: com.facebook.react.uimanager.LayoutShadowNode#setFlexBasis I really have no idea what I'm doing here, just trying to get UIExplorer to compile and run so I can test my upcoming PRs. ~~Unfortunately, this doesn't actually make the apps run, but at least it does get rid of the startup exception!~~ Edit: it works now. **Test plan:** Run Movies and UIExplorer example app Closes facebook#11896 Differential Revision: D4418927 Pulled By: mkonicek fbshipit-source-id: 34788b790b6bfc46ff39a0d9ca1698a5c20662e1
1 parent c7e3819 commit 237ee2d

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagersPropertyCache.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import android.view.View;
1313

1414
import com.facebook.common.logging.FLog;
15+
import com.facebook.react.bridge.Dynamic;
1516
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
1617
import com.facebook.react.bridge.ReadableArray;
1718
import com.facebook.react.bridge.ReadableMap;
@@ -114,6 +115,22 @@ public void updateShadowNodeProp(
114115
protected abstract @Nullable Object extractProperty(ReactStylesDiffMap props);
115116
}
116117

118+
private static class DynamicPropSetter extends PropSetter {
119+
120+
public DynamicPropSetter(ReactProp prop, Method setter) {
121+
super(prop, "mixed", setter);
122+
}
123+
124+
public DynamicPropSetter(ReactPropGroup prop, Method setter, int index) {
125+
super(prop, "mixed", setter, index);
126+
}
127+
128+
@Override
129+
protected Object extractProperty(ReactStylesDiffMap props) {
130+
return props.getDynamic(mPropName);
131+
}
132+
}
133+
117134
private static class IntPropSetter extends PropSetter {
118135

119136
private final int mDefaultValue;
@@ -331,7 +348,9 @@ private static PropSetter createPropSetter(
331348
ReactProp annotation,
332349
Method method,
333350
Class<?> propTypeClass) {
334-
if (propTypeClass == boolean.class) {
351+
if (propTypeClass == Dynamic.class) {
352+
return new DynamicPropSetter(annotation, method);
353+
} else if (propTypeClass == boolean.class) {
335354
return new BooleanPropSetter(annotation, method, annotation.defaultBoolean());
336355
} else if (propTypeClass == int.class) {
337356
return new IntPropSetter(annotation, method, annotation.defaultInt());
@@ -361,7 +380,13 @@ private static void createPropSetters(
361380
Class<?> propTypeClass,
362381
Map<String, PropSetter> props) {
363382
String[] names = annotation.names();
364-
if (propTypeClass == int.class) {
383+
if (propTypeClass == Dynamic.class) {
384+
for (int i = 0; i < names.length; i++) {
385+
props.put(
386+
names[i],
387+
new DynamicPropSetter(annotation, method, i));
388+
}
389+
} else if (propTypeClass == int.class) {
365390
for (int i = 0; i < names.length; i++) {
366391
props.put(
367392
names[i],

0 commit comments

Comments
 (0)