1

PersonalSlice.js

 export const updatePersonal = createAsyncThunk("personal/updatePersonal", async (id, {getState})=>{
    const personalDoc = doc(db, "Personal", id)
    await updateDoc(personalDoc, getState().personal.updatePersonal );
});

Main.js

 const updateName = useSelector((state) => state.personal.updatePersonal.name);

const handleUpdateNameChange = (e) => {
        dispatch(changeUpdatePersonalName(e.currentTarget.value))
    }

const handleUpdateSubmit = (e) => {
        e.preventDefault();
        dispatch(updatePersonal({updateName , updateSurname, updateBirthday, updateStartDate, updateDepartment, updatePhone, updateMail}))
    }



 <Form onSubmit={handleUpdateSubmit}>
                        <p className="text-center" style={{ color: "#39ace7" }}>İsim</p>
                        <Form.Control 
                        size = "sm"
                            type="text"
                            name="updatePersonal"
                            onChange={handleUpdateNameChange}
                            value={updateName}
                            required
                            autoFocus
                        />

I can't send the data I want to update in the form to FireBase. My fault is most likely in the parameters.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

0

If you are starting a new project and/or are not required to have your Firebase data loaded into redux, you might want to give reactfire a try before trying react-redux-firebase. In reference to the above function call ,if the profile object contains a key or a list of keys as parameters, you can populate those parameters with the matching value from another location on firebase.

Setting config like this:

  userProfile: 'users', // where profiles are stored in database
  profileParamsToPopulate: [
    'contacts:users'
  ]
}

Results in profile with populated contacts parameter:

  displayName: 'ABC',
  email: 'abc@xyz.com',
  contacts: [
    {
      email: 'efg@xyz.com',
      displayName: 'EFG'
    },
     {
      email: 'pqr@xyz.com',
      displayName: 'PQR
    }
  ]
}

Please check the link here to understand the parameters call usage and related questions Update Data in Firebase and Update function in Firebase for reference.Also check the helpful documentation for configuration for redux-firebase

Vaidehi Jamankar
  • 1,232
  • 1
  • 2
  • 10