Skip to content

Commit

Permalink
fix(miniprogram): 修复循环内使用 ref 的问题,fix #5050
Browse files Browse the repository at this point in the history
计算循环 ref 跑 createData 前,需要先把 Current.index 置空
  • Loading branch information
Chen-jj authored and luckyadam committed Dec 19, 2019
1 parent 36fd185 commit 4e718a2
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/taro-alipay/src/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ function doUpdate (component, prevProps, prevState) {

if (component['$$hasLoopRef']) {
Current.current = component
Current.index = 0
component._disableEffect = true
component._createData(component.state, component.props, true)
component._disableEffect = false
Expand Down
1 change: 1 addition & 0 deletions packages/taro-jd/src/create-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export function componentTrigger (component, key, args) {
}
if (component['$$hasLoopRef']) {
Current.current = component
Current.index = 0
component._disableEffect = true
component._createData(component.state, component.props, true)
component._disableEffect = false
Expand Down
1 change: 1 addition & 0 deletions packages/taro-jd/src/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ function doUpdate (component, prevProps, prevState) {

if (component['$$hasLoopRef']) {
Current.current = component
Current.index = 0
component._disableEffect = true
component._createData(component.state, component.props, true)
component._disableEffect = false
Expand Down
1 change: 1 addition & 0 deletions packages/taro-qq/src/create-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export function componentTrigger (component, key, args) {
}
if (component['$$hasLoopRef']) {
Current.current = component
Current.index = 0
component._disableEffect = true
component._createData(component.state, component.props, true)
component._disableEffect = false
Expand Down
1 change: 1 addition & 0 deletions packages/taro-qq/src/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ function doUpdate (component, prevProps, prevState) {

if (component['$$hasLoopRef']) {
Current.current = component
Current.index = 0
component._disableEffect = true
component._createData(component.state, component.props, true)
component._disableEffect = false
Expand Down
1 change: 1 addition & 0 deletions packages/taro-quickapp/src/create-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ export function componentTrigger (component, key, args) {
if (key === 'componentDidMount') {
if (component['$$hasLoopRef']) {
Current.current = component
Current.index = 0
component._disableEffect = true
component._createData(component.state, component.props, true)
component._disableEffect = false
Expand Down
1 change: 1 addition & 0 deletions packages/taro-quickapp/src/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ function doUpdate (component, prevProps, prevState) {
invokeEffects(component)
if (component['$$hasLoopRef']) {
Current.current = component
Current.index = 0
component._disableEffect = true
component._createData(component.state, component.props, true)
component._disableEffect = false
Expand Down
1 change: 1 addition & 0 deletions packages/taro-swan/src/create-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ function createComponent (ComponentClass, isPage) {
}
if (component['$$hasLoopRef']) {
Current.current = component
Current.index = 0
component._disableEffect = true
component._createData(component.state, component.props, true)
component._disableEffect = false
Expand Down
1 change: 1 addition & 0 deletions packages/taro-swan/src/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ function doUpdate (component, prevProps, prevState) {

if (component['$$hasLoopRef']) {
Current.current = component
Current.index = 0
component._disableEffect = true
component._createData(component.state, component.props, true)
component._disableEffect = false
Expand Down
1 change: 1 addition & 0 deletions packages/taro-tt/src/create-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export function componentTrigger (component, key, args) {
if (key === 'componentDidMount') {
if (component['$$hasLoopRef']) {
Current.current = component
Current.index = 0
component._disableEffect = true
component._createData(component.state, component.props, true)
component._disableEffect = false
Expand Down
1 change: 1 addition & 0 deletions packages/taro-tt/src/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ function doUpdate (component, prevProps, prevState) {

if (component['$$hasLoopRef']) {
Current.current = component
Current.index = 0
component._disableEffect = true
component._createData(component.state, component.props, true)
component._disableEffect = false
Expand Down
1 change: 1 addition & 0 deletions packages/taro-weapp/src/create-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export function componentTrigger (component, key, args) {
}
if (component['$$hasLoopRef']) {
Current.current = component
Current.index = 0
component._disableEffect = true
component._createData(component.state, component.props, true)
component._disableEffect = false
Expand Down
1 change: 1 addition & 0 deletions packages/taro-weapp/src/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ function doUpdate (component, prevProps, prevState) {

if (component['$$hasLoopRef']) {
Current.current = component
Current.index = 0
component._disableEffect = true
component._createData(component.state, component.props, true)
component._disableEffect = false
Expand Down

0 comments on commit 4e718a2

Please sign in to comment.