2017-05-30 1 views
0

Ich bin neu in der Reaktion native, ich möchte Formular hinzufügen, wenn Dropdown geklickt. Ich benutze ModalDropdown Bibliothek. aber ich bin verwirrt, das hinzuzufügen. DankWie füge ich ein Formular aus dem Drop-down-Menü hinzu?

dies ist mein Code

const OPTION_STATUS = ['option1', 'option2', 'option3']; 

class.....{ 
return(
<ModalDropdown 

        options={this.state.status_option} 
        defaultIndex={-1} 
        defaultValue={'Please select Status Update'} 
        onDropdownWillShow={this._status_willShow.bind(this)} 
        onDropdownWillHide={this._status_willHide.bind(this)} 
        onSelect={(idx, value) => this._status_onSelect(idx, value)} 
       /> 
); 

_status_willShow() { 
    setTimeout(() => this.setState({ 
     status_option: OPTION_STATUS, 
    }), 2000); 
    } 

    _status_willHide() { 
    this.setState({ 
     status_option: null, 
    }); 
    } 

    _status_onSelect(idx, value) { 
    console.debug(`idx=${idx}, value='${value}'`); 
    this.setState({status: value}); 
    } 
} 

Antwort

0

Sie müssen die Form in irgendeiner Weise in Ihrem _status_onSelect Funktion wechseln.

Beispiel:

_status_onSelect(idx, value) { 
    console.debug(`idx=${idx}, value='${value}'`); 
    this.setState({status: value, showForm: true}); 
} 

Und dann können Sie die UI-Elemente in Ihrer Render-Methode wie so hinzufügen:

{this.state.showForm ? 
<View> 
    // Your form content here 
</View> 
: null } 
Verwandte Themen