javascript - modifiy multiple react components on trigger -


i have input forms use on several places on single-page website. there single react-component class named subscribe contains whole <form> allowing user enter email , subscribe newsletter.

when user submits subscribes in <subscribe>, want change content of every occurence of <subscribe> on page. easy single <subscribe> user used, can not find suitable way modifiy state of other <subscribe> components. i'm, using plain javascript modifiy dom-nodes.

is there way directly in react?

yeah, better done flux comment said in post. should store changes , manipulate storage data service.

you can check https://facebook.github.io/flux/ further information.

but, if you're rendering page react can set state page , pass 1 prop in each <subscribe> component. should manipulate submission in same page or through mixin not let component job state changed well.

in page:

getinitialstate: function () {     return {         alreadysubscribed: false     }; } 

when user hit subscribe button: this.setstate({alreadysubscribed: true});

when render each <subscribe> component pass prop, example: disablesubscribe={this.state.alreadysubscribe}


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -