Skip to content

Bugfix: reset allows custom initial value, loadAll updates currentIndex #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 24, 2019

Conversation

geoffdavis92
Copy link
Owner

What:

  1. Add support for Floodgate#reset to explicitly pass new initial value to new Floodgate#queue generator
  2. Fix Floodgate#loadAll not updating Floodgate#state.currentIndex

Why:

  1. Floodgate's state locks up if its props are controlled by a parent, exportState is saved by that parent, and Floodgate is toggled between mounted instances in a "loadComplete === true" state
    • When mounting is toggled, exportState could save the currentIndex value which could then be mapped to the initial prop when re-mounted
    • This creates a situation where the initial value is equal to the length of the data prop's value, making the reset method useless
  2. Mostly for testing purposes, but also to ensure a consistent experience between the load methods

How:

  1. Adding the initial property to the Floodgate#reset method's parameter
    • Used in the initialization of a new Generator
    • When not specified, defaults to Floodgate#props.initial
  2. Setting Floodgate#state.currentIndex to the length of Floodgate#data

Reference:

Closes #40
Closes #41

@geoffdavis92 geoffdavis92 added bug Unexpected or error-producing behavior testing Validation of code via Jest or Travis CI labels Jan 22, 2019
@geoffdavis92 geoffdavis92 changed the title Bugfix/40 41 reset loadall fixes Bugfix: reset allows custom initial value, loadAll updates currentIndex Jan 22, 2019
@geoffdavis92 geoffdavis92 merged commit 93e9653 into master Jan 24, 2019
@geoffdavis92 geoffdavis92 deleted the bugfix/40-41_reset-loadall-fixes branch July 1, 2019 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected or error-producing behavior testing Validation of code via Jest or Travis CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant