我正在尝试使用 @reduxjs/Toolkit 触发一个简单的操作,但它不起作用。
我看到该操作已调度,但就像切片减速器没有监听它或其他什么。
const say = createAction("ui/say", what => ({ payload: what }));
const uiSlice = createSlice({
name: "ui",
initialState: { said: "" },
reducers: {
[say.type]: (state, action) => {
console.log("saying", action.payload); //<-- not showing, why?
state.currentList = action.payload;
}
}
});
const store = configureStore({
reducer: combineReducers({
ui: uiSlice.reducer
})
});
const Chat = () => {
const dispatch = useDispatch();
const [whatToSay, setWhatToSay] = useState("");
const whatWasSaid = useSelector(state => state.ui.said);
const onSubmit = e => …Run Code Online (Sandbox Code Playgroud) 我有一个允许的自定义注释列表,并且我正在尝试通过调用contains列表中的方法来检查是否允许特定的注释。这行得通,但是Sonar抱怨统治squid:S2175。它说:
“列表<类>”不能包含“类”
可以使用错误类型的参数来调用几个Collection方法,但这是没有意义的,并且可能是使用错误参数的结果。当List.contains或List.remove的参数类型与用于列表声明的类型无关时,此规则将引发问题。
我怎样才能解决这个问题?
这是一个最小的示例:
private boolean testClassContains(){
final List<Class<? extends Annotation>> annotations = Arrays.asList(MyAnnotation.class,YourAnnotation.class);
return annotations.contains(YourAnnotation.class);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试将在 Namecheap 中注册的域连接到我的 S3 存储桶。
我在这里检查了许多与此相关的问题,但我的配置似乎没问题。
我可以通过AWS提供的静态网站端点访问该网站,但是当我在浏览器中输入自定义域时,需要很长时间才能加载,最后提示页面无法加载。
我等了超过 48 个小时,并多次尝试清理缓存。
我的男朋友可以在他的手机中访问它,但我无法使用我的任何设备访问它(我什至尝试使用我的移动数据)。我还要求我妈妈(她住在另一个国家)尝试访问它,但她不能。
我将我的域名替换为下图中的 example.com。
“example.com”是我的主要存储桶。“www.example.com”只是将所有请求重定向到主存储桶。这是我在主存储桶中使用的存储桶策略:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example.com/*"
}
]
}
Run Code Online (Sandbox Code Playgroud)
以及我在辅助存储桶中使用的那个(www.example.com)
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::www.example.com/*"
}
]
}
Run Code Online (Sandbox Code Playgroud)
当我尝试访问 ping 命令中显示的 IP 地址时,它只显示 S3 主页面。