Chirag, I like the way you keep yourself calm during the interview.
@engineerchirag5 ай бұрын
🙏
@godessGOATАй бұрын
fr
@udaykulkarni5639Ай бұрын
I love how this guy is so patient.. i just couldnt take the way she was coding and testing stuff left and right.. i started skipping in first 10 mins itself. Kudos to you dude..
@AbhishekTiwari-xt1kt6 ай бұрын
Patience was tested
@coderinprocess26786 ай бұрын
I am solving too along with the candidate. I am pausing the video as Chirag keeps on adding the functionality. Practicing thinking out loud while doing this
@engineerchirag6 ай бұрын
Awesome ❤️
@dilshadazam8806 ай бұрын
Your consistency is amazing. With you I have also been consistent. Thanks
@engineerchirag6 ай бұрын
Thank you 🙏
@AbhishekTiwari-xt1kt6 ай бұрын
In order to not toggle the accordion on clicking checkbox, you simply can stop the event propagation from the handle checkbox change function.
@shubhanshusahuu6 ай бұрын
Just use the index of that child accordian, which must be used inside a map function and just set the index inside the state whenever expand event happen, and use a prop "expanded" ={arr[state] === index? true : false} And use this expanded prop inside accordian to apply expanded class Thats it.
@udaykulkarni5639Ай бұрын
This dude KNOWS how to interview 🙌🏼 i would love this dude to interview me.. wouldnt feel bad even if i get rejected.. good job man.
@DebayanMukherjee-wo2ul6 ай бұрын
Learn a lot through your videos.......as a fresher.......keep asking more interesting questions
@engineerchirag5 ай бұрын
Thank you 🙏
@Prince-yz1tc6 ай бұрын
My Solution, it is working but I'm not able to achieve the last functionality where we want to change the checkbox value but not expand the acoordian. I'm not able to debug the issue, why parent is logged in first? import React, { useState } from "react"; import { IoIosArrowDown, IoIosArrowUp } from "react-icons/io"; const Data = [ { id: "1", title: "Accordion Item 1", description: "Content for accordion item 1", checked: false, expanded: false, }, { id: "2", title: "Accordion Item 2", description: "Content for accordion item 2", checked: false, expanded: true, }, { id: "3", title: "Accordion Item 3", description: "Content for accordion item 3", checked: true, expanded: false, }, { id: "4", title: "Accordion Item 4", description: "Content for accordion item 4", checked: false, expanded: false, }, { id: "5", title: "Accordion Item 5", description: "Content for accordion item 5", checked: false, expanded: false, }, ]; const AccordionComp = ({ title, description, id, setExpanded, checked, expanded, toggleCheck, }: { title: string; description: string; id: string; checked: boolean; expanded: boolean; setExpanded: (val: string) => void; toggleCheck: (id: string) => void; }) => { return ( { console.log("parent"); setExpanded(id); }} className="flex justify-between items-center space-x-2" > { e.stopPropagation(); console.log("child"); toggleCheck(id); }} type="checkbox" className="mr-2" name="Check" /> {title} {expanded ? ( ) : ( )} {expanded && } ); }; const Accordion = () => { const [items, setItems] = useState(Data); const isDisabled = !items.every((x) => x.checked); const handleToggleCheck = (id: string) => { setItems((prev) => prev.map((i) => i.id != id ? i : { ...i, checked: !i.checked, } ) ); }; const setExpanded = (id: string) => { setItems((prev) => prev.map((i) => i.id !== id ? { ...i, expanded: false } : { ...i, expanded: true } ) ); }; return ( {items.map((item) => ( ))} Submit ); }; const Description = ({ text }: { text: string }) => {text}; export default Accordion;
@soumyaa18046 ай бұрын
I also faced the same issue. Adding e.stopPropagation() on onClick of the input tag worked for me. Like this e.stopPropagation()} onChange={() => { handleChange(data.id); }} />
@yashsolanki0696 ай бұрын
you need to stop propagating the event
@Prince-yz1tc6 ай бұрын
@@yashsolanki069 Could you explain why? If i stop it'll call both child and parent. At this time, I only wanna call child event handler not parent's.
@sutharpavan13266 ай бұрын
Thank you sir for having this interview!! I would have used a state only for the current expanded item to store the expanded item's id and matching that id with the item's id in the iteration to show the expanded item's content. To prevent the expansion of the item/ accordian on click of the checkbox, we can use e.stopPropagation to prevent notify the parent about the event. Can you please tell in which companies these types of questions are asked? Thanks again.