简体   繁体   中英

Why ReactNative TextInput is implemented this way?

if you have any experience with native Android , you know that each EditText saves its value in itself. i mean in react native you have to update state when user types anything but isn't this bad?

in android you can reach the Edittext and then call some methods like getText() or sth but in react native you have to read the value in state! it means more coupling! because you are using an state for a component which is in another Component for example.

for what reason react native is using this approach which seems old! in older C# you had sth like this approach.

Actually, react support Controlled and Uncontrolled style. Controlled means having all value in sync with form's state. It seems complicated at first but will provide you flexibility in terms of validation and rendering.

Here are some documents you can reference:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM