Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ public class ReactNativeFeatureFlagsOverrides_RNOSS_Stable_Android() :
ReactNativeNewArchitectureFeatureFlagsDefaults() {

override fun useFabricInterop(): Boolean = true

override fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean = true;
override fun enablePropsUpdateReconciliationAndroid(): Boolean = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export default function MyNativeView(props: {}): React.Node {
style={{flex: 1}}
opacity={opacity}
values={arrayValues}
isEnabled={true}
onIntArrayChanged={event => {
console.log(event.nativeEvent.values);
console.log(event.nativeEvent.boolValues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @format
*/

import type {CodegenTypes, HostComponent, ViewProps} from 'react-native';
import {CodegenTypes, HostComponent, ViewProps} from 'react-native';

Check warning on line 11 in packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js

View workflow job for this annotation

GitHub Actions / test_js (20.19.4)

Requires should be sorted alphabetically, with at least one line between imports/requires and code

Check warning on line 11 in packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js

View workflow job for this annotation

GitHub Actions / test_js (22)

Requires should be sorted alphabetically, with at least one line between imports/requires and code

Check warning on line 11 in packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js

View workflow job for this annotation

GitHub Actions / test_js (24)

Requires should be sorted alphabetically, with at least one line between imports/requires and code

import * as React from 'react';
import {codegenNativeCommands, codegenNativeComponent} from 'react-native';
Expand All @@ -30,6 +30,7 @@

type NativeProps = Readonly<{
...ViewProps,
isEnabled?: CodegenTypes.WithDefault<boolean, true>,
opacity?: CodegenTypes.Float,
values: ReadonlyArray<CodegenTypes.Int32>,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ package com.facebook.react.uiapp.component
import android.graphics.Color
import androidx.annotation.ColorInt
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.bridge.WritableNativeMap
import com.facebook.react.module.annotations.ReactModule
import com.facebook.react.uimanager.ReactStylesDiffMap
import com.facebook.react.uimanager.SimpleViewManager
import com.facebook.react.uimanager.StateWrapper
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.ViewManagerDelegate
import com.facebook.react.uimanager.ViewProps
Expand All @@ -34,8 +37,30 @@ internal class MyNativeViewManager :

override fun getName(): String = REACT_CLASS

override fun createViewInstance(reactContext: ThemedReactContext): MyNativeView =
MyNativeView(reactContext)
private var delegatedInitialProps = ReactStylesDiffMap(WritableNativeMap()) // capture props
override fun createViewInstance(
reactTag: Int,
reactContext: ThemedReactContext,
initialProps: ReactStylesDiffMap?,
stateWrapper: StateWrapper?
): MyNativeView {
if (initialProps != null) {
delegatedInitialProps = initialProps
}
return super.createViewInstance(reactTag, reactContext, initialProps, stateWrapper)
}

override fun createViewInstance(reactContext: ThemedReactContext): MyNativeView {
// here, assume that all props from initialProps are urgently needed during view creation
if (!delegatedInitialProps.hasKey("isEnabled")) {
throw IllegalStateException("isEnabled prop is required for MyNativeView!")
// Note: i know that there is .getBoolean(value, defaultFallback).
// But the point is that I don't want to repeat typing the prop name in multiple places.
// "Worse" additionally, the user might has even passed the default value explicitly as prop,
// but its not received here on the native side.
}
return MyNativeView(reactContext /*, someComputedValue */)
}

override fun callNativeMethodToChangeBackgroundColor(view: MyNativeView, color: String) {
view.setBackgroundColor(Color.parseColor(color))
Expand Down Expand Up @@ -80,4 +105,8 @@ internal class MyNativeViewManager :
)
)
)

override fun setIsEnabled(view: MyNativeView?, value: Boolean) {
TODO("setIsEnabled called with value: $value")
}
}
Loading