小编TTT*_*TT2的帖子

React - Redux 重定向到其他组件时如何过滤全局状态

我有一个 React 应用程序,其中使用 redux 设置全局状态,在一个组件中填充表单,并根据输入向同一端点发出 axios 请求,从 redux 获取数据,然后我想重定向到另一个端点组件并根据这个新请求过滤状态。问题是,当我重定向时,会显示 redux 定义的相同状态,而不会显示更新的状态。

\n

我的 redux 逻辑是这样的:

\n

actionsCreatorproductActions.js

\n
import { fetchProductsStart, fetchProductsSuccess, fetchProductsFailure } from '../slices/productsSlice';\nimport { baseUrl } from '../../shared/baseUrl';\n\nexport const fetchProducts = () => async dispatch => {\n  try {\n    dispatch(fetchProductsStart());\n    const response = await fetch(baseUrl+"products");\n    const data = await response.json();\n    dispatch(fetchProductsSuccess(data));\n  } catch (error) {\n    dispatch(fetchProductsFailure(error));\n  }\n};\n
Run Code Online (Sandbox Code Playgroud)\n

切片减速器是productsSlice.js

\n
import { createSlice } from "@reduxjs/toolkit";\n\n\nconst productsSlice = createSlice({\n  name: "products",\n  initialState: {\n    products: [],\n …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs redux react-redux redux-toolkit

5
推荐指数
0
解决办法
152
查看次数

Spring Boot - Custom Authentication Filter without using the WebSecurityConfigurerAdapter

I am trying to migrate a code that used the old springboot security configuration with the WebSecurityConfigurerAdapter to the new component based security config, i have a custom authentication filter that extends UsernamePasswordAuthenticationFilter that want to include in my SecurityFilterChain bean as is showed here:

SecurityConfig.java file

package com.tito.userservice.security;

import com.tito.userservice.filter.CustomAuthenticationFilter;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;

import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;


@Configuration @EnableWebSecurity @RequiredArgsConstructor
public class …
Run Code Online (Sandbox Code Playgroud)

java spring-mvc maven spring-boot

2
推荐指数
1
解决办法
3350
查看次数