react-state-rxjs
  • Introduction
  • Main differences
  • Performance first
  • GETTING STARTED
    • Instalation
    • Examples
  • Core concepts
    • Main idea
      • More complex flow visualization
    • Configuration
    • Store
      • Operators
      • Optimistic updates plugin
      • Form manager plugin
        • ShouldUpdateState hook
        • Custom form elements
      • Persist state plugin
        • Configuring custom storage
    • Actions
      • Immer
      • ImutableJs
      • Async
    • Components with Actions
    • @InjectStore decorator
    • @ComponentState decorator
    • ComponentState Hook
    • Dispatcher
    • Router / History
  • DIFFERENT SCENARIOS
    • Passing list item index via router
  • UNIT TESTING
    • Setup
    • Test store
    • Test actions
    • Test component with actions
    • Test with Enzyme
  • Debugging
    • Setup
    • Redux DevTools
    • Automated changes output
    • Manual state changes check
    • Additional debugging information
  • Production
    • Production mode
  • Other information
    • Best practices
    • CLI
      • Custom Configurations
    • Performance
    • Blog Posts
    • Contributing
Powered by GitBook
On this page

Was this helpful?

  1. Core concepts
  2. Store
  3. Form manager plugin

ShouldUpdateState hook

In some cases you might need to postpone state update to some time for example until field is valid. In this case you can do use shouldUpdateState method

 componentDidMount() {
    this.formStateManager = Store.store.select(['form']).form
        .bind(this.form.current)
        .addCustomFormElements([this.customFormElement.current])
        .shouldUpdateState(this.shouldUpdateState)
        .onChange(state => this.forceUpdate())
        .sync();
}
shouldUpdateState = (params: ShoulUpdateStateParams) => {
    return true;
}

ShouldUpdateStateParams:

  • form: HTMLFormElement - form that has being synced

  • formElements: FormElement[] - all form elements that are being synced

  • target: HTMLElement | CustomFormElement - current html element or custom form element

  • state: any - state before update

  • currentValue: any - current field value

  • value: any - target value

PreviousForm manager pluginNextCustom form elements

Last updated 6 years ago

Was this helpful?