Comments (4)
仔细看了下,User 列表页面会渲染三次:
- model 初始化的时候加载一次,合理。
- effects 中的
const { data, headers } = yield call(usersService.fetch, { page });
这一句会触发渲染。似乎没有必要,因为数据虽然取了回来,但是还没有塞到 model 中。 - reduce 中的 save 修改 model 后会触发一次,合理。
effect 应该是只能读取 state 而不能修改 state,要修改数据,只能在 reduce 中修改。这样 effect 里面的代码应该不会导致页面刷新啊?
from dva-example-user-dashboard.
找到原因了,第二次是由于Step 8. 通过 dva-loading 处理 loading 状态导致的,loading 状态是另外一个 model了,而fetch
会修改这个状态。
由于 React 的机制,在数据没有变化的情况下组件是不会重新加载的,这样只是一个 loading 的变化对整个页面的性能影响关系不大。
from dva-example-user-dashboard.
不能只渲染一次么?
from dva-example-user-dashboard.
@allinshang 这里的做法是先显示空白数据页面,然后取到数据后再次渲染,这样用户体验会好点。当然你也可以先准备好数据,然后再跳转到这个页面。
from dva-example-user-dashboard.
Related Issues (20)
- 开发模式下正常,npm run build后无法加载roadhog.dll.js
- 访问报<Router> may have only one child element错误 HOT 2
- npm run build后写的cssModule样式都无法加载
- 使用命令时报错
- 跑步起来 HOT 1
- 跑不起来,提示 have not run `roadhog buildDll` before `roadhog server`.
- modify special style, but not customize theme HOT 1
- Maybe it would be better to use yarn instead of npm
- 跑不起来 HOT 1
- roadhog.dll.js:1 Uncaught SyntaxError: Unexpected token < HOT 3
- yield put({ type: 'reload' });无效
- dva 创建项目后启动失败,node,npm均正常
- example的依赖是太老跟新的API相冲突 HOT 1
- 点击进入 user 页面不能及时渲染,显示 无数据 HOT 1
- 我按照指定得格式配置,还是报错./src/index.js Module build failed: ReferenceError: Unknown plugin "import" specified in "base" at 4, attempted to resolve relative to "F:\\workSpace\\user-dashboard\\src" at Array.map (native)
- 切换分页数据无变化
- Compiled successfully! You can now view client in the browser. Local: http://localhost:3000/ On Your Network: http://192.168.0.103:3000/ Note that the development build is not optimized. To create a production build, use yarn build.
- 导航栏路由不跳转
- Note that the development build is not optimized. To create a production build, use npm run build.
- Failed to start the server, since you have enabled dllPlugin, but have not run roadhog buildDll before roadhog server
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dva-example-user-dashboard.