提交 4f490366 编写于 作者: fxy060608's avatar fxy060608

fix(mp): pre flush watchers (#3057)

上级 0ced70cc
...@@ -4778,6 +4778,13 @@ function renderComponentRoot(instance) { ...@@ -4778,6 +4778,13 @@ function renderComponentRoot(instance) {
setCurrentRenderingInstance(prev); setCurrentRenderingInstance(prev);
return result; return result;
} }
const updateComponentPreRender = (instance) => {
pauseTracking();
// props update may have triggered pre-flush watchers.
// flush them before the render update.
flushPreFlushCbs(undefined, instance.update);
resetTracking();
};
function setupRenderEffect(instance) { function setupRenderEffect(instance) {
const componentUpdateFn = () => { const componentUpdateFn = () => {
if (!instance.isMounted) { if (!instance.isMounted) {
...@@ -4787,6 +4794,7 @@ function setupRenderEffect(instance) { ...@@ -4787,6 +4794,7 @@ function setupRenderEffect(instance) {
// updateComponent // updateComponent
const { bu, u } = instance; const { bu, u } = instance;
effect.allowRecurse = false; effect.allowRecurse = false;
updateComponentPreRender(instance);
// beforeUpdate hook // beforeUpdate hook
if (bu) { if (bu) {
invokeArrayFns(bu); invokeArrayFns(bu);
......
...@@ -4778,6 +4778,13 @@ function renderComponentRoot(instance) { ...@@ -4778,6 +4778,13 @@ function renderComponentRoot(instance) {
setCurrentRenderingInstance(prev); setCurrentRenderingInstance(prev);
return result; return result;
} }
const updateComponentPreRender = (instance) => {
pauseTracking();
// props update may have triggered pre-flush watchers.
// flush them before the render update.
flushPreFlushCbs(undefined, instance.update);
resetTracking();
};
function setupRenderEffect(instance) { function setupRenderEffect(instance) {
const componentUpdateFn = () => { const componentUpdateFn = () => {
if (!instance.isMounted) { if (!instance.isMounted) {
...@@ -4787,6 +4794,7 @@ function setupRenderEffect(instance) { ...@@ -4787,6 +4794,7 @@ function setupRenderEffect(instance) {
// updateComponent // updateComponent
const { bu, u } = instance; const { bu, u } = instance;
effect.allowRecurse = false; effect.allowRecurse = false;
updateComponentPreRender(instance);
// beforeUpdate hook // beforeUpdate hook
if (bu) { if (bu) {
invokeArrayFns(bu); invokeArrayFns(bu);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册