第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

在 2 個(gè)反應(yīng)組件中使用相同的功能。第二個(gè)不起作用

在 2 個(gè)反應(yīng)組件中使用相同的功能。第二個(gè)不起作用

回首憶惘然 2022-06-09 11:09:46
我與 TypeError 斗爭(zhēng):deleteEducation 不是一個(gè)函數(shù) - 2 個(gè) React 組件中的相同函數(shù)。該組件有效。    import React, { Fragment } from 'react'    import PropTypes from 'prop-types';    import { connect } from 'react-redux';    import Moment from 'react-moment';    import { deleteEducation } from '../../actions/profile';    export const Education = ({ education, deleteEducation }) => {        const educations = education.map(edc => (            <tr key={edc._id}>                <td>                    <button className='btn btn-danger' onClick={() => deleteEducation(edc._id)} >Delete</button>                </td>            </tr>        ));        return (            <Fragment>                <h2 className='my-2'>Education Credentials</h2>                <table className="table">                    <tbody>                        {educations}                    </tbody>                </table>            </Fragment>        )    }    Education.propTypes = {        education: PropTypes.array.isRequired,        deleteEducation: PropTypes.func.isRequired,    }    export default connect(null, { deleteEducation })(Education);這沒有。我想使用另一種不同的方法來刪除Experience()。它不起作用,所以我嘗試了相同的功能,但組件名稱不同。import React, { Fragment } from 'react'import PropTypes from 'prop-types';import { connect } from 'react-redux';import Moment from 'react-moment';import { deleteEducation } from '../../actions/profile';export const Experience = ({ education, deleteEducation }) => {    const educations = education.map(edc => (        <tr key={edc._id}>            <td>                <button className='btn btn-danger' onClick={() => deleteEducation(edc._id)} >Delete</button>            </td>            </tr>    ));    return (            <Fragment>                <h2 className='my-2'>Education Credentials</h2>                <table className="table">                    <tbody>                        {educations}                    </tbody>                </table>            </Fragment>    )}
查看完整描述

2 回答

?
拉丁的傳說

TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超8個(gè)贊

您需要在兩個(gè)組件的連接包裝器中使用參數(shù)分派您的函數(shù)。


改變


export default connect(null, { deleteEducation })(Experience);


const mapDispatchToProps = dispatch => ({

  deleteEducation: id => dispatch(deleteEducation(id))

})

export default connect(null, mapDispatchToProps)(Experience);


查看完整回答
反對(duì) 回復(fù) 2022-06-09
?
烙印99

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超13個(gè)贊

我的導(dǎo)入錯(cuò)誤,未包含在我的帖子中。抱歉 React 自動(dòng)添加了默認(rèn)導(dǎo)入,我沒有注意到。

import { Experience }  from './Experience';
import Education from './Education';


查看完整回答
反對(duì) 回復(fù) 2022-06-09
  • 2 回答
  • 0 關(guān)注
  • 144 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)