RTK-Query 使用需要注意的地方
官方建议 createApi
只应该被调用一次,对于不同领域的 endpoint ,应该使用 injectEndpoints
增加 endpoint ,而不是调用多次 createApi
。
Typically, you should only have one API slice per base URL that your application needs to communicate with. For example, if your site fetches data from both /api/posts and /api/users, you would have a single API slice with /api/ as the base URL, and separate endpoint definitions for posts and users. This allows you to effectively take advantage of automated re-fetching by defining tag relationships across endpoints.