A
A
ajlee42020-03-01 17:53:55
React
ajlee4, 2020-03-01 17:53:55

onfocus implementation in react-native?

Tell me please. It is necessary that the font of the label decreases when the focus is on. I tried to implement it through state, but when focusing on one input, the font decreases on the other, is it possible to implement somehow so that for each input a separate variable in the state does not start?5e5bcc6441e38103187096.png

<Item floatingLabel  style={styles.formField} >
                            <Label style={isFocused ? styles.formLabelActive : styles.formLabel}>Телефон</Label>
                            <Input
                                authFocus
                                value={this.state.phone}
                                onChangeText={phone => this.setState({ phone })}
                                autoCompleteType="tel"
                                onFocus={() => this.setState({ isFocused: true })}
                                onBlur={() => this.setState({ isFocused: false })}
                            />
                        </Item>
                        <Item floatingLabel style={styles.formField}>
                            <Label style={isFocused ? styles.formLabelActive : styles.formLabel}>Пароль</Label>
                            <Input
                                value={this.state.password}
                                onChangeText={password => this.setState({ password })}
                                secureTextEntry={true}
                                autoCompleteType="password"
                                onFocus={() => this.setState({ isFocused: true })}
                                onBlur={() => this.setState({ isFocused: false })}
                            />
                        </Item>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question