@@anshulvairagade1604 every thing is seems readable and fine but why u passed item prop from App component to list component
@anshulvairagade1604 Жыл бұрын
@@bishwajeetpandey1570 item means the element of our array, and that arrar is present in App component, and we are using that particular element and printing it using another list component. To add more logic into it i.e adding check box etc I hope this helps
@bishwajeetpandey1570 Жыл бұрын
This is my solution of this problem import { useState } from "react"; const arr=["Apple", "Orange", "Banana"] export default function App() { const [fruitsArr, setFruitsArr] = useState([...arr]); const [chkBoxStates, setChkBoxStates] = useState(arr.map(()=>false)); const deleteClickHandler = (index) => { alert(index); const filteredArr = []; for (let i = 0; i < fruitsArr.length; i++) { if (i !== index) filteredArr.push(fruitsArr[i]); } setFruitsArr(filteredArr); }; const handleCheck = (isChecked, index) => { setChkBoxStates((prevArray) => { const newArray = [...prevArray]; // create a new array based on the previous state array newArray[index] = isChecked; // modify the element at the specified index return newArray; // return the new array as the updated state value }); }; return ( {console.log("render")} Hello Codeandbox Start editing to see some magic happen! {fruitsArr.map((element, index) => { return ( handleCheck(e.target.checked, index)} >{" "} {element} {chkBoxStates[index] && ( deleteClickHandler(index)}>Delete )} ); })} ); }
@webber5629 Жыл бұрын
But the problem is when i click the checkbox for first item then it's delete button shows and after deleting that item the checkbox for second item is automatically checked and so on.
@pankajpundir6256 Жыл бұрын
To implement this task first you will have to add ischeck key inside the copyarr through map and then pass index and target value through handlechnage function .arr[index] ={..arr[index], ischeck=!arr[index].ischeck !ischeck} and then you make a condition inside the jsx that ischeck==true && Delete
@lipinkariappa3550 Жыл бұрын
i haven't learnt react yet, but ig a simple vanilla js script for deleting part would be this: const buttons = document.querySelectorAll('li button') buttons.forEach((button)=>{ button.addEventListener('click',(event)=>{ event.target.parentNode.remove() }) })
You can create a one sate like: const [checkedInputs, setCheckedInputs] = useState([]); And then add the current index + checkedInputs to checkedInputs state like setCheckedInputs([... checkedInputs, index])
@pranshukumar67074 ай бұрын
For checkboxes we can create an state which will be an array of all the selected boxex item index... This array will be manipulated upon clicking on the checkbox.. Checkbox unchecks and checks itself.. No need to keep a checkbox status in this case.. Now upon clicking a checkbox pass the index of item.. Now check whether the checkbox array state contains that index or not (by using arr.includes (index)).. If yes.. Then splice that index.. If no then push the index in that array.. This way we will always have an array of items index for which checkbox is selected.. Based on that we can do conditional rendering of delete button..
@rizkydjanuar2809 Жыл бұрын
Easy to solve, u can create a component that return a state(it`s called children as a function or if u familiar with callback is same method). Then u can use it after mapping so u create a seperate state and then u can use it to handle show delete button
create child component for each item and manage check state inside that component for each individual list item.
@vaskarchandradas3565 Жыл бұрын
❤U r right brother😊
@subhajit3316 Жыл бұрын
He has lifted the state up i.e state controlled by parent that why when he click another checkbox check become false and button disappeard The solution is that he has to create diff state for diff children
@galax5130 Жыл бұрын
check could be a object or object of arr assign to check state when bool and index were saved and then access the obj according to it.
@proeditz108 Жыл бұрын
He can create an another component for every list item and pass the props for every single list item. Thanks.... 😂😂❤❤
@chillpill610 Жыл бұрын
pl. continue this series , upload videos weekly , help many aspirants
@bardenishi4312 Жыл бұрын
Amazing..... what the helpful video you are making!
@abnow1998 Жыл бұрын
I would have used useReducer Hook to handle checkbox value for that particular input and trigger delete if selected. Simple!!
@anirbandas126 ай бұрын
delete an elem from arr .. let's use filter .. yeah .. if an item is at the last position we need to iterate the whole array and filter ... hmm.. very efficient
@WeakCoder Жыл бұрын
Sir, should we expect these kind of questions for a 2 yrs exp IT person ? Or much harder than this ?
@coderdost Жыл бұрын
if someone is taking a live interview you can expect a similar level. But otherwise a little more harder will be there. Live meaning someone checking while you are coding... but sometime they just given questions and expect you to submit in 2 hours etc. Then it will be much harder.
@kt303011 ай бұрын
These questions can asked for fresher ?@@coderdost
@Yadavladka1086 ай бұрын
@Hitesh Choudhary , best teacher 🎉🎉 thank you sir.
@bishwajeetpandey1570 Жыл бұрын
Wow upload more videos on interview coding round.
@bekizodcancer365711 ай бұрын
in order to render the updated list when the delete button click why not we can use useState hook for the arr array list...any suggestion?
@mitulbhadeshiya480 Жыл бұрын
Thanks for such a good tutorial
@Kakashi-ek1ju Жыл бұрын
How much salary a guy can expect from this level of interview
@parshvsheth-rj2vq4 ай бұрын
Internship
@purusharma8192 Жыл бұрын
Sir your videos are very useful and you also remains cool and calm
@anubhav.codess11 ай бұрын
Delete can be done with the help of splice
@jayanth9445 Жыл бұрын
function ListItem(props) { const [btn, setBtn] = useState(false); const [t, setT] = useState(true); function handlePress(event) { // console.log(event.target.value); setBtn(!btn); } function handleClick(event){ setT(false); } return ( {props.name} delete ); }
Sir how i can I build logic in react 😊..some one help me
@sui16chillax75 Жыл бұрын
very simple question, god did it very first try , so i think god is god always right
@aveenism Жыл бұрын
is it for fresher or how many experienced level question
@NavneetTaneja-d1y Жыл бұрын
input pain click nahi change event lagta hain
@shailenderjaiswal1685 Жыл бұрын
this is very nice
@blackpurple9163 Жыл бұрын
Interview me ese hi questions puchhte he kya? For freshers? I'm applying for MERN stack
@coderdost Жыл бұрын
They may ask simple conceptual questions also as given in this playlist : kzbin.info/aero/PL2PkZdv6p7ZnxpstmVUbybt5M9hjTayY_ These type of questions are asked in companies which take some time to evaluate candidates for React skill - otherwise they may ask even plain programming question or DS question. There is no set rule
I think there is no good question sets available. generally better to work on some small projects. that itself is a good practice.
@yikanaveen Жыл бұрын
Sir , i'm doing BBA from regular private college and I have skill in MySQL ,php, javascript,html , css so can I get job in it sector? Please tell me
@coderdost Жыл бұрын
PHP is still used but competition is high, from old developers. You will have to try with some internships at a company where they use PHP or some PHP based framework. Laravel is top framework these days. PHP is not high paying initially, but it is a widely used language still.
@yikanaveen Жыл бұрын
@@coderdost sir i know i asking that i am BBA student so can i get jobs in it sector if i had THAT skills
@4444-c4s Жыл бұрын
@@yikanaveen kyu nahi...companies ko bus skills chahiye...Projects banao aur dikhaao
@coderdost Жыл бұрын
@@yikanaveen Yes, however your first job will be hard to crack in traditional IT companies which filter based on degreee and field. So you have to try for startups and companies which are remote work based and looking for skills rather than background of degree. After first job, things change.. and experience matters.
@roxxxxxy Жыл бұрын
chatgpt be like: bas itna hi abhi kar deta hu
@coderdost Жыл бұрын
🤣
@shayanalijalbani9894 Жыл бұрын
It's a good practice to create a state like const [state, setState] = useState() And not like this const [state, setName] = useState()
@vivekkumar-pc1xy Жыл бұрын
thanks, very informative video
@swapnaar5329 Жыл бұрын
Hi Vivek, do you know any telugu reactjs developers or full stack developers in india? Please let me know if they need any extra income.
@iamdevil9485 Жыл бұрын
which software is he using?
@coderdost Жыл бұрын
Online code editor. Syncfiddle
@hitman5161 Жыл бұрын
How can i give the mock interview to you
@coderdost Жыл бұрын
Generally we release a form on channel community
@gorikhanna6070 Жыл бұрын
@@coderdostcan u plz tell me how to give mock interview to u ???
@coderdost Жыл бұрын
@@gorikhanna6070 We put up a from on community post for mock interviews. you can apply once that is available.
@karanbhoite9552 Жыл бұрын
Experience???
@coderdost Жыл бұрын
Fresher
@jeth2600 Жыл бұрын
I want to know about that it's scripted or not. Or The student already know the question.
@coderdost Жыл бұрын
No student is joining live
@jeth2600 Жыл бұрын
@@coderdost TQ for reply And he can use Google.
@mayankmisra00 Жыл бұрын
hi sir can you give the solution of that problem ? function sayHello(){ console.log("Hello"); } function sayHi(){ console.log("sayHi") } function add(a,b,fun){ sayHello() sayHi(10) console.log(a+b) } add(10,20,sayHello) here i can call the sayHi() fuction in the add function()
@jayeshmahajan4213 Жыл бұрын
i guess sayhi() fun no console any value because its not access in fun add
@harrycullen863 Жыл бұрын
Is this for freshers or experience
@coderdost Жыл бұрын
Freshers. But for some for experienced dev also they ask simple question initially and then ask to add something to it.. live interviews …dont have very hard questions .. hard ones are given in take home assignments or machine round without a live interviewer
@mauliingle832211 ай бұрын
chai aur code
@sarojregmi200 Жыл бұрын
will it be considered a pass ??
@coderdost Жыл бұрын
Depends on post, for fresher level it is PASS. as only few ppl can really code in live situation and limited time.
@zaneyt3791 Жыл бұрын
It's easy for me
@shreyanshmishra6613 Жыл бұрын
Do it without react with vanilla js
@zaneyt3791 Жыл бұрын
@@shreyanshmishra6613 for sure brother
@stan1slav937 Жыл бұрын
Wow, so basic problem and he cant resolve it , very weak guy
@coderdost Жыл бұрын
live coding makes people nervous, specially when other person is looking every second.
@@sandeepgaur98223 I have maintained a state named "showDelete" which contain array of todo. Now how it worked : Whenever user click on checkbox , handleCheckbox will be triggered and in this function I have passed value (checked state which is further not used in function definition) and another is todo which are using in function definition . So showDelete.includes(todo) this line checked that current todo is present in state or not , if yes then we are filtering it and if not then we are adding it due to this We are using further this state to show Delete button corresponding to checkbox on the basis of corresponding todo is present in that state or not. Hope it is clear?
@sandeepgaur98223 Жыл бұрын
@@rathore_shantilal Thanks! It was indeed a very clear and to the point explanation!