-
Notifications
You must be signed in to change notification settings - Fork 3
Billy - React challenge submission #7
base: main
Are you sure you want to change the base?
Conversation
const saveButtonClick = (renderForm, policyNumber) => { | ||
console.log('In saveButtonClick') | ||
// grab value of select and pass into dispatch as policyType | ||
const select = document.getElementById('select-policy-type'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting approach to changing the select-policy-type
element. Is there any reason why you didn't change the element with jsx, but instead chose a getElementById
call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Candidly, I was short on time and this was the most intuitive way for me! A little hacky, but first and foremost I just wanted to make sure I could get it done and implement the functionality.
case types.ADD_POLICY_TYPE: { | ||
console.log('In ADD_POLICY_TYPE action'); | ||
policyTypes = state.policyTypes.slice(); | ||
policyTypes.push(action.payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this approach, you are keeping two copies of the policyTypes - one in the policies array and another in the policyTypes array. If you had more time, would you have done this differently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding was that we wanted to keep both the policies array and the policyTypes array (both from provider.js
) in the store. The policyTypes array in store felt redundant/unnecessary to me in general, but the prompt instructed me to import all the policy types from the policyTypes array in provider.js
:
Both the policies array retrieved from getPolicies and the policyTypes array from getPolicyTypes should be stored in the redux store.
I may be misunderstanding your question, though!
Let me know if you need anything else!