react-native-website icon indicating copy to clipboard operation
react-native-website copied to clipboard

Please update Direct Manipulation docs with `setNativeProps`'s deprecation status

Open AlanSl opened this issue 3 years ago • 3 comments
trafficstars

Description

It's currently unclear if setNativeProps is deprecated or not:

  1. From the documentation, there's no signs of any deprecation - https://reactnative.dev/docs/direct-manipulation
  2. I see that the react-native-renderer had set to show deprecation warnings when element.setNativeProps was used; these were then removed in https://github.com/facebook/react/pull/17045 but it appears the intention is still to deprecate, just not show warnings in existing apps?
  3. There are various references to setNativeProps not being supported at all in Fabric. Presumably this includes the setNativeProps(ref) usage as well as the element.setNativeProps usage? For example see:
    • https://github.com/facebook/react/pull/15094
    • Comments under https://github.com/facebook/react/issues/18499

What is the problem?

It should be clear from the latest version of the docs what the status is. Are either or both of the element.setNativeProps and/or setNativeProps(ref) usage patterns deprecated?

How can we address it?

Please update the docs to say what the current status (e.g. I think it's not supported in Fabric, and is planned to be deprecated?)

Why is it important?

If a decision has been made to deprecate or drop a feature, that should be apparent from the docs; if it's not then the docs aren't succeeding in being the main source of truth on such things.

Currently it appears a decision has been made, but it's not clear what that decision is because it's fragmented across various issues, discussions, PR comments etc.

Who needs this?

Any developer using or considering using setNativeProps.

When should this happen (use version numbers if needed)?

Depends on what the status is (I can't see for sure because the discussion is fragmented).

AlanSl avatar May 05 '22 12:05 AlanSl

We have a paragraph about it in the New Architecture documentation here: https://reactnative.dev/docs/new-architecture-library-intro#migrating-off-setnativeprops

You won't be able to use setNativeProps in the New Architecture. Therefore, if you wish to migrate to the New Architecture you should refrain from using it.

As the New Architecture is still experiemental, this API is not deprecated yet.

cortinico avatar May 06 '22 15:05 cortinico

Great, thanks for the clarification.

And to be clear - this applies equally to the element.setNativeProps({ ...props }) usage as it does to the setNativeProps(ref, { ...props }) usage - it's no longer true that one is favoured over the other?

My understanding now is that there was a plan to deprecate element.setNativeProps({ ...props }) in favour of setNativeProps(ref, { ...props }), on the assumption that the former would not be supported in Fabric and the latter would; but then thinking shifted towards supporting neither in Fabric, so the idea of specifically deprecating element.setNativeProps({ ...props }) was dropped?

So in the short term, the two usages are equally well supported, and in the long term, it's likely they will both be dropped from the new architecture at the same time (but not confirmed yet because the new architecture is still experimental)?

AlanSl avatar May 09 '22 09:05 AlanSl

👋 Hey there, it looks like there has been no activity on this issue in the last 90 days. Has the issue been fixed, or does it still require the community attention? This issue will be closed in the next 7 days if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Aug 08 '22 02:08 github-actions[bot]

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

github-actions[bot] avatar Aug 15 '22 02:08 github-actions[bot]