•  


Revert "Remove setNativeProps API" change · Issue #2633 · necolas/react-native-web · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Remove setNativeProps API" change #2633

Open
1 task done
niklasmachacek opened this issue Jan 25, 2024 · 4 comments
Open
1 task done

Revert "Remove setNativeProps API" change #2633

niklasmachacek opened this issue Jan 25, 2024 · 4 comments
Labels
enhancement Requires extension or creation of new React Native API

Comments

@niklasmachacek
Copy link

niklasmachacek commented Jan 25, 2024

Is there an existing request?

  • I have searched for this request

Describe the feature request

Back in March last year, the setNativeProps API was removed , since back then the react-native team said that the API would not be supported in Fabric.

This changed as of now as it can be read here .

It would only make sense to get setNativeProps API back into react-native-web again since many people are relying on the API (for example for text input animations) and it is now officially supported in Fabric after react 0.72.

There is also a discussion about this here , where many people agree that this would be the best change.

@niklasmachacek niklasmachacek added the enhancement Requires extension or creation of new React Native API label Jan 25, 2024
@necolas
Copy link
Owner

setNativeProps never worked correctly on web and had undefined behaviour on native. If the fabric implementation has defined behaviour, there's still no reliable way to implement it on web while styles are not simply inline styles. The primary use case of setNativeProps was updating styles without a render, but it's just not reliable on web. Things like text input animations aren't done this way on web either. The new RN architecture will eventually allow for sync events and sync updates, providing the same event loop model as web, so the setNativeProps pattern will likely have fewer reasons to be used on native

@jonathanj
Copy link

@necolas I appreciate the technical concerns here?thank you!?and I'm sure it's not easy to convey without the reader already having some context around the implementation.

From my point of view, setNativeProps in RNW (0.18) works well-enough for styles (which might be because of how styles work in RNW 0.18) but more importantly works for setting text input values without round-tripping via the React lifecycle. My use case is for things like formatted text inputs between focus/blur.

I have previously tried to remove setNativeProps in favour of the suggested state-based approaches, but I ran into update cascades/loops (certainly in the native code), and overall introduces more complexity and fragility than setNativeProps for these types of tasks. For style updates?such as handling hover? setNativeProps is perceptibly more responsive than the state round-trip.

Do you think there's some way forward where a "use at own risk" type API is introduced for setNativeProps for these difficult edge cases? Or is this a hard line from your point of view?

@dalcib
Copy link

facebook/react-native@ 1d3fa40

Add setNativeProps to Fabric

Summary:
changelog: Introduce setNativeProps to Fabric

Add support for setNativeProps in Fabric for backwards compatibility. It is still recommended to move away from setNativeProps because the API will not work with future features.

We can make step Migrating off setNativeProps in migration guide optional.

Reviewed By: yungsters, mdvacca

Differential Revision: D41521523

fbshipit-source-id: 4d9bbd6304b8c5ee24a36b33039ed33ae1fc21f8

@necolas
Copy link
Owner

@jonathanj For now I think you could use Platform.OS forks to use setNativeProps on native and direct manipulation on web. Eventually RN will support the same direct manipulation APIs as web, and will support sync updates that make things like managing text input content better than it is today.

Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment
Labels
enhancement Requires extension or creation of new React Native API
Projects
None yet
Development

No branches or pull requests

4 participants
- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본