Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function AccountEditor() {
const classes = useStyles()
const firebase = useFirebaseApp()
const auth = useUser()
const accountRef = firebase.database().ref(`users/${auth.uid}`)
const profileSnap = useDatabaseObject(accountRef)
const profile = profileSnap.snapshot.val()
function updateAccount(newAccount) {
return firebase
.updateProfile(newAccount)
.then(() => accountRef.update(newAccount))
.catch(error => {
console.error('Error updating profile', error.message || error) // eslint-disable-line no-console
return Promise.reject(error)
})
}
return (
const Counter = props => {
const database = useDatabase();
const ref = database().ref('counter');
const increment = amountToIncrement => {
ref.transaction(counterVal => {
return counterVal + amountToIncrement;
});
};
const { snapshot } = useDatabaseObject(ref);
const counterValue = snapshot.val();
return (
<>
<button> increment(-1)}>-</button>
<span> {counterValue} </span>
<button> increment(1)}>+</button>
);
};