Firebase React和Material-UI中未显示的值

时间:2019-12-12 13:44:51

标签: reactjs firebase firebase-realtime-database redux

我有一个问题,我可以调度并将其推送到Firebase,但是Firebase中没有数据,字符串为空。我想知道Material-ui是否在这里引起问题,还是我遗漏了什么?这也是代码。我一直在试图找出为什么值不显示的原因,并且一直想知道代码中的某个地方有错误,因为我认为它应该在技术上可行,并且

empty values

//动作

import firebase from 'firebase';
import { toast } from 'react-toastify';
import { 
    CREATE_USER,
    UPDATE_FORM
} from './ActionTypes';

export const formUpdate = ({ prop, value }) => {
    console.log("LOG", prop, value)
    return {
        type: UPDATE_FORM,
        payload: { prop, value }
    }
}

export const createProfile = ({ firstName, lastName, email, company, billingMethod }) => {
    // const { currentUser } = firebase.auth();

    return (dispatch) => {
        firebase.database().ref(`/profile`)
            .push({ firstName, lastName, email, company, billingMethod })
            .then(() => {
                dispatch({ type: CREATE_USER })
            })
            .then(() => {
                toast.info("User profile was created !", {
                    position: toast.POSITION.BOTTOM_CENTER,
                    autoClose: 1000
                  });
            })
    }
}

//减速器

import {
    CREATE_USER,
    UPDATE_FORM
} from '../Actions/ActionTypes';


const INITIAL_STATE = {
    firstName: '',
    lastName: '',
    email: '',
    company: '',
    billingMethod: '',
}

export default (state = INITIAL_STATE, action: any) => {
    switch (action.type) {
        case UPDATE_FORM:
            return { ...state, [action.payload.prop]: action.payload.value }
        case CREATE_USER:
            return INITIAL_STATE
        default:
            return state
    }
}

1 个答案:

答案 0 :(得分:0)

在pastebin.com/TepX1Tgv中,定义const getStepContent = (step, props) => {...}时,它需要两个参数。

实现它时,您只能传递一个参数

<Typography className={classes.instructions}>{getStepContent(activeStep)}</Typography>

传递props参数,以便所有组件都可以接收其props。