Skip to content
This repository has been archived by the owner on Mar 7, 2019. It is now read-only.

Hotfix registration to add sane default name #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

logandavis
Copy link
Contributor

The register button literally just doesn't work without this commit. Please merge it.

name: 'Test User',
entryYear: '2001',
major: 'Mechanical Engineering',
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}

https://jsfiddle.net/owsteele/5wk3tzLf/1/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants