Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
¿Cómo actualizar un valor con reductor a través de la entrada de texto?

Me gustaría actualizar el valor de una variable en el reductor. En la aplicación, el usuario puede escribir el nombre de usuario en un campo de entrada de texto en una pantalla. El reductor debería actualizar este estado para que pueda mostrarlo en una pantalla diferente. En este momento estoy usando useState pero me gustaría usar el reductor en su lugar. Soy nuevo en la codificación y realmente estoy luchando con esto, así que espero que alguien pueda ayudarme.

El reductor:

 import { createSlice } from '@reduxjs/toolkit'; const userSlice = createSlice({ name: 'user', initialState: " ", reducers: { setUser: (state = initialState, action) => { ??? }, } }); export const {setUser} = userSlice.actions; export default userSlice.reducer;

Código en la pantalla con useState:

 const [user, setUser] = useState(""); const [userName, setUserName] = useState(""); const onValueChange = (number) => setUser(number); const onButtonHandler = () => setUserName(user); <View style= {globalStyles.containerInput}> <TextInput style= {globalStyles.input} maxLength={20} minLegth={10} keyboardType="number-pad" value={user} onChangeText={onValueChange} /> </View> <View style= {globalStyles.containerButton}> <Pressable style={globalStyles.button} onPress={onButtonHandler} > </Pressable> </View>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!