Hotfix registration to add sane default name#37
Conversation
| name: 'Test User', | ||
| entryYear: '2001', | ||
| major: 'Mechanical Engineering', | ||
| }); |
There was a problem hiding this comment.
The code above actually overwrites everything in account and newAccount with name: 'Test User' etc., even if newAccount.name has a value. Not sure if that's what you wanted.
To merge the objects with precedence to supplied newAccount properties, use:
const account = Object.assign({name: 'Test User', entryYear: '2001', major: 'Mechanical Engineering'}, newAccount) (if you keep the defaults as an object literal – in that case, the literal is mutated into the merged object each time)
or
const account = Object.assign({}, AccountDefaults, newAccount) (if you move the defaults to a global).
If you're using redux, you've probably got Babel / webpack set up with the object rest spread operator. In that case, you can also write
const account = {...AccountDefaults, ...newAccount}
The register button literally just doesn't work without this commit. Please merge it.