samedi 21 octobre 2017

How to implement the condition in reactjs request?

I have Request Like this previosly:

let data = {

      chartLibraryType : this.state.chartCategory == 'highChart'? "HIGH_CHARTS" : "C3",

    };

Now i need to implement with 3. Along with highcharts and c3 i need to pass d3 also.

let data = {

      chartLibraryType : if(this.state.chartCategory == 'highChart'){
                            "HIGH_CHARTS"
                        }else if(this.state.chartCategory == 'c3Chart'){
                            "C3"
                        }else if(this.state.chartCategory == 'D3Chart'){
                            "D3"
                            },

    };

Is this the way to implement when we have more than 2.

Aucun commentaire:

Enregistrer un commentaire