Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

43
Vistas
Using onChangeText and onFocus to alter style of a text block

Refering to the code below, how can I write it so that when onFocus and onChangeText is called, the value of marginTop changes from 3 to 5?

       <Block>
          <Text marginTop={3}>TEXT</Text>
          <Block>
            <Input
              keyboardType="phone-pad"
              placeholder="Phone number"
              defaultValue={details?.phone}
              onChangeText={(value) => onChange({ phone: value })}
              onFocus?
            />
          </Block>
        </Block>

Any hint would be greatly appreciated. Thanks in advance.

7 months ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

margin changes when either onChangeText or onFocus is called

 const [changeMargin, setChangeMargin] = useState(false)  ;
    <Block>
                  <Text marginTop={changeMargin ? 5: 3}>TEXT</Text>
                  <Block>
                    <Input
                      keyboardType="phone-pad"
                      placeholder="Phone number"
                      defaultValue={details?.phone}
                      onChangeText={(value) => { if(value !=null && value.length >0){setChangeMargin(true) ;}else{setChangeMargin(false) ;};
 onChange({ phone: value })}}
                      onFocus={()=>{setChangeMargin(true)}}
                    />
                  </Block>
                </Block>
7 months ago · Santiago Trujillo Denunciar

0

const [move, setMove] = useState(false)
<Block>
  <Text marginTop={3}>TEXT</Text>
  <Block>
    <Input
      keyboardType="phone-pad"
      placeholder="Phone number"
      defaultValue={details?.phone}
      onChangeText={(value) => setMove(true)
      style={move && /* do something*/}
      onFocus?
    />
  </Block>
</Block>
7 months ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.