I have some nested state in class component that I want change it to functional component, but I don't know how can I use nested state in functional component with hook and useState
and also useEffect
? can you help me please?
state = {
products: null,
totalPrice: 0,
addCounter: 0,
purchased: false,
loading: false,
form: {
name: {
elementType: 'input',
elmentConfig: {
type: 'text',
palceholder: 'Name...',
},
value: '',
validation: {
required: true,
},
valid: false,
used: false,
},
password: {
elementType: 'input',
elmentConfig: {
type: 'password',
palceholder: 'Password...',
},
value: '',
validation: {
required: true,
},
valid: false,
used: false,
},
email: {
elementType: 'input',
elmentConfig: {
type: 'text',
palceholder: 'Email...',
},
value: '',
validation: {
required: true,
},
valid: false,
used: false,
},
},
};