Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
Unable To Map Over Dummy Data

I'm creating a mapped out component with some dummy data in the frontend. I have just some quick data i'm pulling from a js file

export const userInputs = [
    {
        id: 1,
        label: "First Name",
        type: "text",
        placeholder: "Remy"
    },
    {
        id: 2,
        label: "Surname",
        type: "text",
        placeholder: "Sharp",
    },
    {
        id: 3,
        label: "Email",
        type: "email",
        placeholder: "remysharp@gmail.com",
    }
]

I am then feeding this as an 'inputs' prop, as such

<UserProfile inputs={userInputs}/>

I have this passed in as a props to my component, however when I try to map out this as:

              <UpdateUserDetails>

                {inputs.map((input) => (
                  <FormInput key={input.id}>
                    <UserInput type={input.type} placeholder={input.placeholder}>
                  </UserInput>
                  </FormInput>
                ))}

              </UpdateUserDetails>

I get the following error × TypeError: Cannot read properties of undefined (reading 'map')

What am I missing?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I primarily use React native (Expo: https://docs.expo.dev/) now a days so my code looks a little different, but it appears you were just missing the index. Feel free to play around with the following

import { StyleSheet, Text, View, TouchableOpacity } from 'react-native'

export const inputs = [
  {
    id: 1,
    label: 'First Name',
    type: 'text',
    placeholder: 'Remy',
  },
  {
    id: 2,
    label: 'Surname',
    type: 'text',
    placeholder: 'Sharp',
  },
  {
    id: 3,
    label: 'Email',
    type: 'email',
    placeholder: 'remysharp@gmail.com',
  },
]

export default function App() {
  return (
    <View>
      {inputs.map((input, index) => (
        <TouchableOpacity key={input.id}>
          <Text>{inputs[index]?.label}</Text>
        </TouchableOpacity>
      ))}
    </View>
  )
}

I just placed userInputs as inputs in the same file for simplicities sake.

I hope this helps. Have a great rest of your night!

about 4 years 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 vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda