{"action":"closed","issue":{"url":"https://api.github.com/repos/Idrottskoll/idrottskoll-app/issues/3","repository_url":"https://api.github.com/repos/Idrottskoll/idrottskoll-app","labels_url":"https://api.github.com/repos/Idrottskoll/idrottskoll-app/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/Idrottskoll/idrottskoll-app/issues/3/comments","events_url":"https://api.github.com/repos/Idrottskoll/idrottskoll-app/issues/3/events","html_url":"https://github.com/Idrottskoll/idrottskoll-app/issues/3","id":269417557,"number":3,"title":"Warning: Cannot update during an existing state transition","user":{"login":"jeremydanner","id":20877209,"avatar_url":"https://avatars3.githubusercontent.com/u/20877209?v=4","gravatar_id":"","url":"https://api.github.com/users/jeremydanner","html_url":"https://github.com/jeremydanner","followers_url":"https://api.github.com/users/jeremydanner/followers","following_url":"https://api.github.com/users/jeremydanner/following{/other_user}","gists_url":"https://api.github.com/users/jeremydanner/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremydanner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremydanner/subscriptions","organizations_url":"https://api.github.com/users/jeremydanner/orgs","repos_url":"https://api.github.com/users/jeremydanner/repos","events_url":"https://api.github.com/users/jeremydanner/events{/privacy}","received_events_url":"https://api.github.com/users/jeremydanner/received_events","type":"User","site_admin":false},"labels":[{"id":705163560,"url":"https://api.github.com/repos/Idrottskoll/idrottskoll-app/labels/bug","name":"bug","color":"ee0701","default":true},{"id":705163563,"url":"https://api.github.com/repos/Idrottskoll/idrottskoll-app/labels/help%20wanted","name":"help wanted","color":"33aa3f","default":true},{"id":705163566,"url":"https://api.github.com/repos/Idrottskoll/idrottskoll-app/labels/question","name":"question","color":"cc317c","default":true},{"id":734481475,"url":"https://api.github.com/repos/Idrottskoll/idrottskoll-app/labels/react-native","name":"react-native","color":"d4c5f9","default":false},{"id":734482628,"url":"https://api.github.com/repos/Idrottskoll/idrottskoll-app/labels/react-redux","name":"react-redux","color":"bfd4f2","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-10-29T17:25:39Z","updated_at":"2017-10-31T14:58:07Z","closed_at":"2017-10-31T14:58:07Z","author_association":"CONTRIBUTOR","body":"I want to update my component in my `render()` method when a user has been logged in. But I get a strange warning: `Warning: Cannot update during an existing state transition (such as within render or another component's constructor). Render methods should be a pure function of props and state; constructor side-effects are an anti-pattern, but can be moved to componentWillMount.`\r\n\r\nWhat's also strange is that when the user signs in `state.auth.authenticated` is `true` for about a second and goes back to `false` when the warning arrives... How do I fix this and why does it happen? I can not find anything on google or stack-overflow who can help me. \r\nI would also like to add that the component is not updated when the user submits the sign in form.\r\nHere's my code: \r\n``` \r\n'use strict';\r\n\r\nimport React from 'react';\r\nimport { View, Text, TouchableOpacity } from 'react-native';\r\nimport { AsyncStorage } from 'react-native';\r\nimport { connect } from 'react-redux';\r\n\r\nimport DefaultCard from '../../components/Cards/DefaultCard';\r\nimport MyProfileCard from '../../components/Cards/MyProfileCard';\r\nimport ViewContainer from '../../components/ViewContainer';\r\nimport ScrollViewContainer from '../../components/ScrollViewContainer';\r\n\r\nimport MainStyles from '../../assets/styles/MainStyles';\r\nimport Signin from '../../components/auth/Signin';\r\nimport Signout from '../../components/auth/Signout';\r\nimport Signup from '../../components/auth/Signup';\r\n\r\nclass ProfileScreen extends React.Component {\r\n    constructor(props) {\r\n        super(props);\r\n        this.renderCompomponent = this.renderCompomponent.bind(this);\r\n        this.renderUnAuth = this.renderUnAuth.bind(this);\r\n        this.renderAuth = this.renderAuth.bind(this);\r\n    }\r\n\r\n    async show() {\r\n        const showToken = await AsyncStorage.getItem('token');\r\n        alert(showToken);\r\n    }\r\n\r\n    renderUnAuth() {\r\n        return (\r\n            <View>\r\n                <Signin />\r\n                <Signup />\r\n            </View>\r\n        );\r\n    }\r\n\r\n    renderAuth() {\r\n        return (\r\n            <View>\r\n                <DefaultCard>\r\n                    <MyProfileCard />\r\n                </DefaultCard>\r\n\r\n                <TouchableOpacity\r\n                    style={MainStyles.BUTTON_SUCCESS}\r\n                    onPress={() => this.show()}\r\n                >\r\n                    <Text style={MainStyles.BUTTON_SUCCESS_TEXT}>\r\n                        Show token\r\n                    </Text>\r\n                </TouchableOpacity>\r\n\r\n                <Signout />\r\n            </View>\r\n        );\r\n    }\r\n\r\n    renderCompomponent() {\r\n        return (\r\n            <View>\r\n                <TouchableOpacity\r\n                    style={MainStyles.BUTTON_SUCCESS}\r\n                    onPress={() => this.forceUpdate()}\r\n                >\r\n                    <Text style={MainStyles.BUTTON_SUCCESS_TEXT}>\r\n                        Rendera om\r\n                    </Text>\r\n                </TouchableOpacity>\r\n                {this.props.authenticated\r\n                    ? this.renderAuth()\r\n                    : this.renderUnAuth()}\r\n            </View>\r\n        );\r\n    }\r\n\r\n    render() {\r\n        const { navigate } = this.props.navigation;\r\n        console.log(this.props.authenticated);\r\n        return (\r\n            <ViewContainer>\r\n                <ScrollViewContainer>\r\n                    {this.renderCompomponent()}\r\n                </ScrollViewContainer>\r\n            </ViewContainer>\r\n        );\r\n    }\r\n}\r\n\r\nfunction mapStateToProps(state) {\r\n    return { authenticated: state.auth.authenticated };\r\n}\r\n\r\nexport default connect(mapStateToProps)(ProfileScreen);\r\n\r\n```"}}
{"actor":{"display_login":"jeremydanner"}}