2017-11-13 5 views
0

도와주세요. 내가 오류가있어 "정의는Apollo resetStore가 작동하지 않습니다.

class FeedProfileBottom extends Component { 

_onLogoutPress = function() { 
    this.props.client.resetStore(); 
    return this.props.logout(); 
} 

render() { 
    return (
    <Root> 
     <LogOutButton onPress={this._onLogoutPress}> 
     <LogOutText> 
      Logout 
     </LogOutText> 
     </LogOutButton> 
    </Root> 
); 
} 
} 

export default withApollo(connect(undefined, { logout })(FeedProfileBottom)); 
+0

구성 요소 범위를 로그 아웃 함수에 명시 적으로 바인딩 해 보았습니까? –

+0

@ NickZuber 덕분에 효과가있었습니다. – petros

+0

질문에 대한 대답으로이 내용을 추가했습니다. 이것이 해결 된 방법이라면 다른 사람들에게 올바른 것으로 표시해 주시겠습니까? 솔루션을 발견하기 위해 유사한 문제가있는 사용자는 누구입니까? –

답변

0

명시 적 함수에 구성 요소의 범위를 결합해야 할 수도 있습니다 ('this.props.client을'평가) 대상이 아닙니다.

class FeedProfileBottom extends Component { 
    constructor (props) { 
    super(props); 
    this._onLogoutPress = this._onLogoutPress.bind(this); 
    } 
    // ...