Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

filter buttons react

var A = polls.filter(e => e.type === "A")
var B = polls.filter(e => e.type === "B")
var C = polls.filter(e => e.type === "C")    


function showA() {
    setfilteredPolls(A)
}

function showB() {
    setfilteredPolls(B)
}

function showC() {
    setfilteredPolls(C)
}
Comment

filter buttons react

return (
  <div className="polls">
    <button onClick={() => showA()}>A</button>
    <button onClick={() => showB()}>B</button>
    <button onClick={() => showC()}>C</button>

    {
      filteredPolls && filteredPolls.map((poll) => (
        <div key={poll.id}>
          <PollCard poll={poll} />
          <hr style={{ opacity: '.1' }} />
        </div>

      ))
    }
  </div>
);
Comment

PREVIOUS NEXT
Code Example
Javascript :: print stuff in console javascript 
Javascript :: javascript get last 2 item in array 
Javascript :: puppeteer stealth popup 
Javascript :: two dimensional array in javascript 
Javascript :: pass value inside the js file using script tag 
Javascript :: js filter text 
Javascript :: push array into array javascript 
Javascript :: set input type file value empty in react 
Javascript :: jquery is not defined error in wordpress 
Javascript :: postman environment variable 
Javascript :: find element in an array and replace it by a callback function 
Javascript :: link external file by url using javascript 
Javascript :: webpack vue global variable 
Javascript :: common javascript errors 
Javascript :: Merging Or Copying Arrays Using Spread Operator 
Javascript :: amcharts 
Javascript :: JavaScript if, else, and else if 
Javascript :: how to decode jwt token at frontend 
Javascript :: concat no and string in javascript 
Javascript :: local reference in angular 
Javascript :: trigger mouseover on element devtools 
Javascript :: axios put api in componentDidMount React 
Javascript :: react select 
Javascript :: react native cli sdk.dir 
Javascript :: ?? javascript 
Javascript :: Kendo grid export to Excel all pages 
Javascript :: nextjs local storage 
Javascript :: Discord.js v13 / command handler 
Javascript :: how to use if else statement in javascript 
Javascript :: javascript add inline style css var 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =