Skip to content

Commit a9639c4

Browse files
author
David Silva
committed
fixed acessing properties in profile component
1 parent 7c48320 commit a9639c4

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/components/profile/index.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Helmet } from 'react-helmet';
88
import { PROD_URL, BACKEND_URL } from '../../constants';
99
import ReactMarkdown from 'react-markdown';
1010
import SubmitList from '../submit/list';
11+
import _get from 'lodash/get';
1112

1213
class ProfileComponent extends React.Component {
1314
static propTypes = {
@@ -25,9 +26,9 @@ class ProfileComponent extends React.Component {
2526
<meta property="og:type" content="profile" />
2627
<meta property="og:title" content={ `Check ${profile.name}'s developer profile in codecorgi` } />
2728
<meta property="og:url" content={ `${PROD_URL}/${profile.profile_url}` } />
28-
<meta property="og:image" content={`${profile.avatar.url || corgiImg}` } />
29+
<meta property="og:image" content={`${_get(profile, 'avatar.url', undefined) || corgiImg}` } />
2930
<meta name="twitter:title" content={ `codecorgi - ${profile.name}'s developer profile` } />
30-
<meta name="twitter:image" content={`${profile.avatar.url || corgiImg}` } />
31+
<meta name="twitter:image" content={`${_get(profile, 'avatar.url', undefined) || corgiImg}` } />
3132
</Helmet>
3233
<section className="tint-bg img-bg-softer" style={{ backgroundImage: `url(${bgImage})` }}>
3334
<div className="container header-container">
@@ -40,13 +41,13 @@ class ProfileComponent extends React.Component {
4041
<header>
4142
<h1>
4243
<div className="profile-image">
43-
{!profile.avatar.url && <img src={corgiImg} alt={profile.name} />}
44-
{profile.avatar.url && <img src={profile.avatar.url} alt={profile.name} />}
44+
{!_get(profile, 'avatar.url', undefined) && <img src={ corgiImg } alt={ profile.name } />}
45+
{_get(profile, 'avatar.url', undefined) && <img src={ _get(profile, 'avatar.url', '') } alt={ profile.name } />}
4546
</div>
46-
<span>{profile.name}</span>
47+
<span>{ profile.name }</span>
4748
</h1>
48-
<p>{profile.profile.tagline}</p>
49-
<p><i className="icon-___location" /> {profile.profile.___location}</p>
49+
<p>{ _get(profile, 'profile.tagline', '') }</p>
50+
<p><i className="icon-___location" /> { _get(profile, 'profile.___location', '') }</p>
5051
</header>
5152
</div>
5253
</div>
@@ -55,7 +56,7 @@ class ProfileComponent extends React.Component {
5556
<section className="container profile-body" style={{ margin: '30px auto' }}>
5657
<div className="row">
5758
<div className="col-xs-12">
58-
<ReactMarkdown source={ profile.profile.bio } />
59+
<ReactMarkdown source={ _get(profile, 'profile.bio', '') } />
5960
</div>
6061
</div>
6162
{submits && submits.length > 0 &&

0 commit comments

Comments
 (0)