September 2017
Intermediate to advanced
216 pages
6h 8m
English
When we create a new episode and add it to the list of episode maps, we're actually updating two pieces of state. We're updating the results state because this is where the episodes list is located. We're also updating the create state to reset the form field values back to empty strings:
document .querySelector('form[name="create-episode"]') .addEventListener('submit', (e) => { e.preventDefault(); app(state => state .updateIn( ['results', 'episodes'], episodes => episodes.push( Map(state.get('create').toJS()) ) ) .setIn(['create', 'title'], '') .setIn(['create', 'director'], '') .setIn(['create', 'date'], '') ); });
Here we're chaining together several mutative methods that change the state of the application. First, ...
Read now
Unlock full access