reactjs - how to make an observable in react with other library -


i have component return <textinput /> import other library. textinput has onchange prop take function function(value) { // value}.so how can make observable value , use observable anywhere?

import textinput 'otherlibrary'; import rx 'rxjs/rx';  export default class mycomponent extends purecomponent {      handletextchange = (value) => {         this.observable = rx.observable.from(value).do(() => console.log(value))         // how make observable `value`? if make this, every time input letter in textinput make new observable, that's not correct.     }     render() {          return (                      <textinput                         defaultvalue=""                         onchange={this.handletextchange}                     />          );     } } 

if component react compoment, in onchange store in component's state using

this.setstate({textinputvalue: value}) 

(to correct need change onchange callback following:)

<textinput         defaultvalue=""         onchange={this.handletextchange.bind(this)} /> 

now, whenever state changes, , example, passing state prop component, component re-render.

to actual value out of textinput in on change if recall correctly, should use value.target.value, , maybe rename value parameter else avoid confusion,

handlechange = (e) => {..  value= e.target.value 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -