• Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Precios
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

82
Vistas
After i fetch data and add it to redux my react app throws error a variable is not defined

After i fetch data and add it to redux my react app throws error: Uncaught TypeError: Cannot read properties of undefined (reading 'embed') at line 371. Here is line 371:

<input name="color" type="color" className="color-pick" id="embed_color" ref={embedColor} defaultValue={config.guild.welcomeConfig.embed.embedColor} />

Here is the fetch:

export const saveWelcomeConfig = (guildId, config ) => 
    axios({
        method: 'POST',
        url: url + `config/${guildId}/savewelcome`,
        data: {
            welcomeConfig: config
        },
        withCredentials: true
    })

And here is the action:

export const saveWelcomeConfig = (config, guildId) => async (dispatch) => {
    try{
        const { data } = await api.saveWelcomeConfig( guildId, config )

        
        dispatch({
            type: 'SAVE_WELCOME_CONFIG',
            payload: data
        })
    }catch(err){
        console.log(err)
    }
}

And the embed is in my redux's state. After i refresh page its working. But i dont want to refresh the page.

9 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

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