Giter Site home page Giter Site logo

Comments (6)

stratospark avatar stratospark commented on May 24, 2024

@dvshur This looks like the perfect place for redux-saga. Look into some of the examples

Basically, your parent component Updater should be attached to a saga. This saga can takeEvery action dispatched clicking the submit button, then handle that in a sub-saga. Inside that sub-saga, you can dispatch the form validation, wait for a response, then dispatch success or error actions. Your reducers can listen for these actions and update your UI state accordingly.

Hope this puts you on the right track.

from prism.

dvshur avatar dvshur commented on May 24, 2024

Inside that sub-saga, you can dispatch the form validation

@stratospark, but parent component sagas (and the updater as well, for that matter) only have access to parent component actions, while Form 'Validate' is a Form action. Child component's actions are supposed to be encapsulated in a child.

In this case I rather need a way for a parent component to affect the child's state (upon receiving its 'Submit' action on button click)

from prism.

biirus avatar biirus commented on May 24, 2024

@stratospark there is some cons.

  • you should know exact the same type of action which has been dispatched from button component at form component. And it will break whole component encapsulation.
  • you are able to place action watchers whole over components tree. It will cause some unexpected side-effects.

There is a good article about components communication https://facebook.github.io/react/tips/communicate-between-components.html. I do prefer props-callback style, but it don't solve sibling communication.

from prism.

tomkis avatar tomkis commented on May 24, 2024

Elm is all about top-down hierarchy approach, so yes probably the right Elmish approach would indeed be moving the state information up to the parent.

from prism.

tomkis avatar tomkis commented on May 24, 2024

Even plain React explains that pretty-well https://facebook.github.io/react/docs/lifting-state-up.html

from prism.

q13 avatar q13 commented on May 24, 2024

Need more approach

from prism.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.