Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit f60d186

Browse files
committed
Don't modify an object that is passed to components as props
React (and Relay) discourage you from modifying objects that are passed to components as props: https://reactjs.org/docs/components-and-props.html#props-are-read-only. The "data" passed to the Issueish constructor is sent directly from the props passed to IssueishListController, so we should treat them as immutable. I thought that React froze objects passed as props in development mode to catch these issues. That's what's failing on CI - I have no idea why it isn't failing locally for us.
1 parent 3266621 commit f60d186

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/models/issueish.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ import {GHOST_USER} from '../helpers';
66

77
export default class Issueish {
88
constructor(data) {
9-
if (data.author === null) {
10-
data.author = GHOST_USER;
11-
}
9+
const author = data.author || GHOST_USER;
1210

1311
this.number = data.number;
1412
this.title = data.title;
1513
this.url = new URL(data.url);
16-
this.authorLogin = data.author.login;
17-
this.authorAvatarURL = new URL(data.author.avatarUrl);
14+
this.authorLogin = author.login;
15+
this.authorAvatarURL = new URL(author.avatarUrl);
1816
this.createdAt = moment(data.createdAt, moment.ISO_8601);
1917
this.headRefName = data.headRefName;
2018
this.headRepositoryID = data.repository.id;

0 commit comments

Comments
 (0)