react-doctor/rn-no-set-native-props
Drive the prop via state, an Animated.Value (useNativeDriver: true), or a Reanimated shared value instead of imperative setNativeProps
- Category: Bugs
- Severity: warn
- Source:
oxlint-plugin-react-doctor - Framework: react-native
- Enabled when: framework=react-native and capabilities=react-native
- Tags: react-native
- Default: Enabled
Validate the diagnostic
Confirm the reported code matches this rule before you edit it.
Fires on a CallExpression whose callee is a static non-computed .setNativeProps member access AND whose receiver is itself a static non-computed .current member access — i.e. the *.current.setNativeProps(...) or optional-chained *.current?.setNativeProps(...) React host-ref shape (e.g. inputRef.current.setNativeProps({ text }), this.rootViewRef.current.setNativeProps(...), or a chained inputRef.current?.textInputRef.current?.setNativeProps(...)). The rule deliberately only matches the ref .current escape hatch. False positives a reviewer should SUPPRESS: an uncalled member access used as a value (const fn = ref.current.setNativeProps), setNativeProps on a non-.current receiver such as a plain config/options object (config.setNativeProps({...})), a callback-ref form with no .current (iconRef.setNativeProps(...), explicitly out of v1 scope), and other imperative ref methods (inputRef.current.focus()).
How to fix
Follow the rule guidance while preserving unrelated behavior.
Copyable fix prompt
Copy this self-contained prompt into your coding agent after you confirm the diagnostic.
Related rules
More Bugs rules from the rules reference:
react-doctor/rn-no-single-element-style-array: Use `style={value}` instead of `style={[value]}` — single-element arrays add unnecessary allocationreact-doctor/rn-platform-shaking-use-direct-import: Platform reached through React Native namespacereact-doctor/rn-prefer-content-inset-adjustment: Drop the SafeAreaView wrapper and set `contentInsetAdjustmentBehavior="automatic"` on the ScrollView for native safe-area handlingreact-doctor/rn-prefer-expo-image: Use `<Image>` from `expo-image` instead of `react-native` — same prop API, plus disk + memory caching, placeholders, and crossfadesreact-doctor/rn-prefer-pressable: Use `<Pressable>` from react-native (or react-native-gesture-handler) instead of legacy Touchable* components