Skip to content

Instantly share code, notes, and snippets.

@slooock
Created September 19, 2019 23:47
Show Gist options
  • Save slooock/78246ac70846804f497e8a601d90f38d to your computer and use it in GitHub Desktop.
Save slooock/78246ac70846804f497e8a601d90f38d to your computer and use it in GitHub Desktop.
const [values, setValues] = React.useState({
id: '',
name : "",
email: "",
cpf: "",
telephone: [],
birthData: "",
office: "",
address: "",
complement: "",
});
useEffect(() => {
async function loadEmployee(){
let employeeId = props.location.pathname.toLocaleString().split(':')[1].substring(3, 23);
const usuario = await props.firebase.doSearchIdInsert('Users', employeeId);
const user = {id: employeeId, ...usuario};
await setValues(user);
setValues({...values,["telephone"]:user.telephone});
console.log(user.telephone);
}
loadEmployee().then(()=>{console.log(values)});
},[]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment