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.