Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit49b0950

Browse files
committed
fixed CarsPage
1 parent45c45e9 commit49b0950

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

‎src/features/pages/CarsPage.js‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
importReact,{useEffect}from"react";
2-
import{connect}from"react-redux";
2+
import{useDispatch,useSelector}from"react-redux";
33
import{carData}from"../../_fixtures/mockCarData";
44
importCarfrom"../car/Car";
55
importOptionsfrom"../option/Options";
66
import{addAllCars}from"../../store/actions/car";
77

8-
constCarsPage=({ cars, addAllCars})=>{
8+
constCarsPage=()=>{
9+
constdispatch=useDispatch();
10+
constcars=useSelector((state)=>state.car.cars);
11+
912
useEffect(()=>{
1013
// simulate ajax load
1114
setTimeout(()=>{
12-
addAllCars(carData);
15+
dispatch(addAllCars(carData));
1316
},500);
14-
},[addAllCars]);
17+
},[dispatch]);
1518

1619
return(
1720
<div>
@@ -30,12 +33,4 @@ const CarsPage = ({ cars, addAllCars }) => {
3033
);
3134
};
3235

33-
constmapStateToProps=(state)=>({
34-
cars:state.car.cars,
35-
});
36-
37-
constmapDispatchToProps={
38-
addAllCars,
39-
};
40-
41-
exportdefaultconnect(mapStateToProps,mapDispatchToProps)(CarsPage);
36+
exportdefaultCarsPage;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp