这是根据页面返回数据的钩子
const {
data,
isFetching,
isLoading,
isError,
} = useGetResourceQuery(page, perPage );
Run Code Online (Sandbox Code Playgroud)
这是 API
export const api = createApi({
baseQuery: fetchBaseQuery({
baseUrl: "http://localhost:3001",
}),
tagTypes: ["resource"],
endpoints: (build) => ({
getResource: build.query({
query: (page = 1, perPage = 20) =>
`resource?spage=${page}&limit=${perPage}`,
}),
}),
});
export const {useGetResourceQuery} = api
Run Code Online (Sandbox Code Playgroud)
有什么方法可以提取所有查询的状态吗?我想实现基于滚动的分页(无限滚动)需要更新中间件吗?或者有什么方法可以访问状态并将其公开为上面的函数,我浏览了文档但找不到解决方案
我可以使用本地状态并将它们连接起来,但想知道是否可以使用 RTK
谢谢
我正在使用 Material UI v4,我正在从单个文件导出我的样式,但这些样式在其他组件中不起作用。styles.js
const useStyles = makeStyles(theme => ({
root: {
display: 'flex',
},
// textField component styles
textFieldInput: {
margin: theme.spacing(2),
width: 250,
minWidth: 250,
},
formControl: {
margin: theme.spacing(2),
minWidth: 120,
},
})
export {useStyles}
Run Code Online (Sandbox Code Playgroud)
在我的组件文件中
....
const classes = useStyles(styles);
return (
<TextField
className={classes.textFieldInput}
label={label}
placeholder={label}
error={touched && invalid}
helperText={touched && error}
{...input}
disabled={disabled || false}
readOnly={readOnly || false}
required={required || false}
InputProps={{ readOnly, ...custom }}
{...custom}
/>
);
....
Run Code Online (Sandbox Code Playgroud)
当我在我的组件中使用它时,样式将在第一次热重载时起作用,但之后样式不会有任何影响,为什么?以及我如何解决这个问题