亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

反應: 類型錯誤: 調度不是一個函數

反應: 類型錯誤: 調度不是一個函數

慕婉清6462132 2022-09-11 20:18:58
我想從重復中獲取。我正在學習本教程:https://codesandbox.io/s/react-redux-application-hewdb?file=/src/pages/PostsPage.js但是當我在代碼中使用它時,那就是:import React, { useState, useEffect } from 'react';import { connect } from 'react-redux';import {fetchInterview} from '../actions/interviewActions'const DetailInterview = (props, { dispatch, loading, interviews, hasErrors }) => {  console.log("test interview",interviews)  useEffect(() => {    const { match: { params: { id } } } = props;    dispatch(fetchInterview(id))  }, [dispatch])  const interviewslist = interviews  console.log('interview: ', interviews)  return (    <div>      <h3>All participants</h3>      <table>        <thead>          <tr>            <th>ID</th>            <th>Interview id</th>            <th>Partcipants id</th>            <th>Time</th>          </tr>        </thead>        <tbody>          {            console.log('interviews:sad ', interviews)          }          {            interviews? interviews.map((interview) => {              console.log('sadassad',interview)              console.log('sadaghahhgsghssad',interviews)              return (                <tr key={interview.id}>                  <td>{interview.id}</td>                  <td>{interview.interview_id}</td>                  <td>                    {/* <Link to={`/posts/${post.id}`}> */}                    {interview.participant_id}                    {/* </Link> */}                  </td>                  <td>{interview.created_at}</td>                </tr>              )             }) : null          }        </tbody>      </table>    </div>  );}// export default DetailInterview;const mapStateToProps = state => ({  loading: state.interview.loading,  interviews: state.interview.interview,  hasErrors: state.interview.hasErrors,})export default connect(mapStateToProps)(DetailInterview)我收到一個錯誤: 未捕獲的類型錯誤: 調度不是一個函數無法理解這背后的錯誤是什么。
查看完整描述

1 回答

?
慕田峪9158850

TA貢獻1794條經驗 獲得超7個贊

您正在從詳細信息查看的第二個參數中解構值,而您應該從屬性中執行此操作,因為 mapStateToProps 中的值和連接可用作所連接組件的 props

const DetailInterview = (props) => {
    const { dispatch, loading, interviews, hasErrors } = props;
    ...
}


查看完整回答
反對 回復 2022-09-11
  • 1 回答
  • 0 關注
  • 90 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號