fatihinn
KPCKevin Powell - Community
•Created by fatihinn on 11/15/2024 in #front-end
React reducer giving error
Although the value returned to me should be 8 categories, the returned value is undefined and returns 0.
When called with an action of type "GetCategoriesSuccess", the slice reducer for key "categoryListReducer" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.
actionTypes.js
export const getCategoriesSuccess = "GetCategoriesSuccess";
categoryActions.js
import * as actionTypes from "./actionTypes";
export function getCategoriesSuccess(categories) {
return { type: actionTypes.getCategoriesSuccess, categories };
}
export function getCategories() {
return function (dispatch) {
debugger;
let url = "http://localhost:3000/categories";
return fetch(url)
.then((response) => response.json())
.then((result) => dispatch(getCategoriesSuccess(result)));
};
}
initialState.js
export default {
categories: []
}
categoryListReducer.js
import * as actionTypes from "../actions/actionTypes";
import initialState from "./initialState";
export default function categoryListReducer(
state = initialState.categories,action
) {
switch (action.type) {
case actionTypes.getCategoriesSuccess:
return action.payload;
default:
return state;
}
}
2 replies
KPCKevin Powell - Community
•Created by fatihinn on 11/6/2024 in #front-end
Routes Route and render={(props) => ()} using
I started an old course and the video shows that it has a rendering feature like this. I researched it and I think it is used with the Switch structure. Am I doing something wrong or what is the correct one?
<Routes>
{/* <Route
exact
path="/"
render={(props) => (
<ProductList
products={this.state.products}
addToCart={this.addToCart}
currentCategory={this.state.currentCategory}
info={productInfo}
/>
)}
/> */}
<Route exact path="/" element={<NotFound />} />
<Route element={<NotFound />} />
</Routes>
<ProductList
products={this.state.products}
addToCart={this.addToCart}
currentCategory={this.state.currentCategory}
info={productInfo}
/>``
When I use it this way, it brings the data to the home page without any problems, but when I type it in the comment line, the data does not come. The place where the data should come is empty2 replies
KPCKevin Powell - Community
•Created by fatihinn on 11/19/2022 in #back-end
phpMyAdmin - Error
18 replies
KPCKevin Powell - Community
•Created by fatihinn on 11/19/2022 in #back-end
php function doesn't work on hosting but working localhost
69 replies
KPCKevin Powell - Community
•Created by fatihinn on 11/16/2022 in #back-end
php function does not work on hosting
1 replies
KPCKevin Powell - Community
•Created by fatihinn on 10/22/2022 in #front-end
Downgrade from 4 to 2 in 1 row
6 replies
KPCKevin Powell - Community
•Created by fatihinn on 9/28/2022 in #back-end
I need Fast 'charity' wordpress theme
I need a fast charity wp theme. I have 4 theme. How can I test which of them is fast or slow? i use pagespeed insights and I reached 38 39 results, are these good? Is this how I should look at theme speed?
15 replies