kamin
kamin

Reputation: 33

EditableText [blueprintJS] How do you access the new text value? REACT

I am developing with REACT

I would like to use BlueprintJS EditableText to update the text of some labels.

http://blueprintjs.com/docs/#core/components/editable-text

How would I use the updated text in a function/request when onConfirm is triggered?

Lets say I have an component similar to this, where the constructor gives some text to the state.

this.state = {
  text: this.props.text,
  updateText: ''
}

and in the render method, I render

< EditableText

value=this.state.text

onConfirm={someFunction(xxx)} />

where the 'xxx' is the new text value of the EditableText field?

Also, how would I override the inherited styles when isEditing is true?

Upvotes: 0

Views: 1235

Answers (1)

Mikhail Chibel
Mikhail Chibel

Reputation: 1955

You will need to define a function and pass that function as props to the component.

class YourComponent extends React.Component {

    constructor(props) {
        super(props);
        this.handleChange = this.handleChange.bind(this);
    }

    handleChange = (value) => {
        // whatever you want to do for example, change the state 
        //this.setState({ value: value});
    };

    // and this is how you register the callback with the component 
    render () {
        return
            <EditableText
                value={this.state.text}
                onConfirm={this.handleChange} />
            />
    }
 }

Upvotes: 1

Related Questions