Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

stack overflow multiselect error react

import MultiSelect from "react-multi-select-component";
...


const [invoices,set_invoices] = useState([]);
const [selected, setSelected] = useState([]);

function test(options, filter) {
    if (!filter) {
        return options;
    }
    var data={'invoice_number':'22'}
    axios.post('http://localhost:4000/get_invoice_by_number',data).then(
        response => {
            /* Matching the array elements to be like {lable:'',value:''} */
            var temp_invoices=[];
            for(var i =0;i<response.data.length;i++){
                temp_invoices.push({
                    label:response.data[i].invoice_number,
                    value:response.data[i].invoice_number
                })
            }
            /* This is updating the list with response.data that is coming from the API */
            set_invoices(temp_invoices);
            console.log('FIRED')

        },error =>{
            console.log(error);
        }
    )
    return options;

}


<MultiSelect
    options={invoices}
    value={selected}
    labelledBy={"Select"}
    onChange={setSelected}
    filterOptions={test}
/>
Comment

PREVIOUS NEXT
Code Example
Javascript :: pageSize useEffect 
Javascript :: single data class value api respone 
Javascript :: how to get a set of values in mogodb 
Javascript :: express roteamento 
Javascript :: lookup objects 
Javascript :: samesite cookies/console.log 
Javascript :: using Canvas with tkinger draw arc 
Javascript :: how to convert html string to jsx element 
Javascript :: how-can-i-implement-joi-password-complexity-in-joi-validation 
Javascript :: mui datatable onrowdelete 
Javascript :: react three fiber set cursor pointer 
Javascript :: adonis model inheritance 
Javascript :: html5 javascript json vertical colom grap 
Javascript :: realtime database get by field 
Javascript :: javascript merge modification in objects 
Javascript :: parcel react 
Javascript :: how do i set CORS policy for nodejs sever 
Javascript :: angularjs how to get a response from a post request 
Javascript :: angularjs getting Error: [$rootScope:inprog] $digest already in progress when changed from Fetch to $http + $q 
Javascript :: Se Chartjs horizontal 
Javascript :: Using animateCamera in functional components in react native 
Javascript :: Save multiple radios checked on LocalStorage 
Javascript :: PAN SNAP 
Javascript :: yaml request body json 
Javascript :: jquery event element in viewport 
Javascript :: Remove # id From URL When Clicked On Href Link 
Javascript :: select final 2 indexes in JS 
Javascript :: add defer in tag manager 
Javascript :: miragejs createServer timing 
Javascript :: como hacer un contador de tiempo en javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =