我有一个用react和Firebase编写的管理页面 . 在我的管理页面中,我想为用户创建一个帐户(用户名,电子邮件,电话号码,地址,密码) . 但是我的代码不起作用,不会返回错误 .

这是表单创建用户

import { auth, db } from '../../../../../../firebase';
const INITIAL_STATE = {
    username: '',
    email: '',
    password: '',
    phone: '',
    address: '',
    error: null,
};

const byPropKey = (propertyName, value) => () => ({
    [propertyName]: value,
});

class FormUser extends Component {
    constructor(props) {
        super(props);
        this.state = { ...INITIAL_STATE };
    }
    onSubmit = (event) => {
        const {
            username,
            email,
            password,
            phone,
            address,
        } = this.state;
        auth.doCreateUserWithEmailAndPassword(email, password)
            .then(authUser => {
                // Create a user in your own accessible Firebase Database too
                db.doCreateUser(authUser.user.uid, username, email, password, phone, address)
                    .then(() => {
                        this.setState({ ...INITIAL_STATE });
                    })
                    .catch(error => {
                        this.setState(byPropKey('error', error));
                    });
            })
            .catch(error => {
                this.setState(byPropKey('error', error));
            });

        event.preventDefault();
    }
    render() {
        const {
            username,
            email,
            password,
            phone,
            address,
            error,
        } = this.state;

        return (
           ...
            <form onSubmit={this.onSubmit}>
                <div className="form-group">
                    <label className="control-label">User Name</label>
                    <input className="form-control form-white"
                        type="text"
                        id="username"
                        required
                        placeholder="User Name"
                        value={username}
                        onChange={event => this.setState(byPropKey('username', event.target.value))}
                    />
                    <input ... email />
                    <input ... phone />
                    <input ... address />
                    <input ... password />
                </div>      
            </form>

            <div className="modal-footer">
                <button type="button" className="btn btn-secondary waves-effect" data-dismiss="modal">Close</button>
                <button className="btn btn-block btn-gradient waves-effect waves-light" type="submit" disabled={isInvalid}>Create User</button>
                {error && <p>{error.message}</p>}
            </div>
        )
    }
}

export default FormUser;

这是db.js.

import { db } from './firebase';
export const doCreateUser = (id, username, email, phone, address, password) =>
  db.ref(`users/${id}`).set({
    username,
    email,
    phone,
    address,
    password
  });

版本:“firebase”:“^ 5.5.0”,“react”:“^ 16.5.1”,