2017-02-21 64 views
1

自动更新我正在开发,它使用反应-滑动式的部件的组件。当用户向左或向右滑动时,卡片值会改变。阵营不是在生产版本

const values = [ 
'1', 
'2', 
'3', 
'5', 
'8', 
'13', 
'20', 
'40' 
] 

export default class UserContainer extends React.PureComponent{ 
constructor() { 
    super(); 
    this.state = { 
     currentIndex: 0, 
     cardValue:values[0] 
    } 
    this.swipedRight = this.swipedRight.bind(this);  
} 

swipedRight(){   
    var newIndex = this.state.currentIndex; 
    if(newIndex !== 0){ 
     newIndex-=1; 
     this.setState({ 
      currentIndex : newIndex, 
      cardValue: values[newIndex] 
     }); 
    } 
} 

render(){  
    return( 
     <Grid> 
      <Row is="center"> 
       <div style={{width:'170px'}} className={this.state.animationClass}> 
        <Swipeable onSwipedUp={this.swipedUp} onSwipedRight={this.swipedRight} onSwipedLeft={this.swipedLeft} >     
         <User cardValue={this.state.cardValue} userName={this.props.params.userName} />                   
        </Swipeable> 
       </div> 
      </Row> 
     </Grid>                     
    ); 
} 
} 

当我运行npm-start(我正在使用create-react-app)时,它工作正常。我使用heroku部署它,首先运行npm run build,然后推送到heroku master。

当我尝试使用我的应用程序在生产中,该路由工作,但是当我刷卡(使用Chrome切换设备工具栏)它不会自动更新。如果我按F12,则会更新。我想知道什么是错的。

我的应用程序的链接是:https://poc-planning-poker.herokuapp.com/

1)使用上述 2链接)选项卡上的#1,单击新建房间,然后复制roomId 3)在标签#2,填写昵称打开两个标签,粘贴代码领域的roomId,然后点击加入

标签#1应与谁刚刚加入的用户自动更新(它的工作在开发中ENV)。它只会更新,如果我按F12,这很奇怪。

任何想法吗?

编辑:源代码是在这里:https://github.com/danruziska/poc-planning-poker

EDIT2:我也意识到,当我在数组中使用的setState,它调用渲染,但用户界面不会自动更新。如果我SETSTATE一个值,它的工作原理...

回答

0

我发现这个问题(种)。与我使用的另一个组件有冲突:react-inline-grid。当我拿到网格时,它再次运行。

+0

不是一个真正的解决方案,这是为什么网格中的问题? – bobber205