Is it possible to set the data for companyLogo as a const without saving to state? And have that variable available within the render function to pass as props to a component as you see below.
The data for companyLogo is only available once a user logs in so please note the use of the componentDidMount function.
I'm sure there is a more elegant way of doing this, just unsure how.
@connect((store) => {
return {
user: store.user
}
})
export default class Header extends Component {
constructor() {
super();
this.state = {
companyLogo: null
}
}
componentDidMount() {
//Get company logo and store to pass as props
this.setState({
companyLogo: this.props.user.user.groups[0].logoUrl
})
}
render() {
return (
<div className="header-container">
<Row className="header-body">
<Branding companyLogo={this.state.companyLogo} />
<AskQuestion />
<Navigation />
<Profile />
</Row>
</div>
)
}
}
<Branding companyLogo={this.props.user.user.groups[0].logoUrl} />?