You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Does create-react-app have any default css preproccesor included ? If No, which package provides the capability to have abc.scss files in the project.
A: sass-loader
B: node-scss
C: node-sass
D: Yes, it already has a Preprocessor
Answer
Answer: C
2. Which one is the right syntax to dispatch an action to update the Redux store.
import{useDispatch}from"react-redux";import{addToCart}from"../actions/cartActions";constProductCard=(props)=>{const{ eachListItem }=props;constdispatch=useDispatch();return(<divclassName="prod-card"><divclassName="btn-contn"><buttonclassName="btn"onClick={()=>/*Enter Your Code*/}>
Add to Cart
</button></div></div>);};
A: dispatch().addToCart(eachListItem)
B: dispatch(addToCart(eachListItem))
C: dispatch.addToCart(eachListItem)
D: None of the Above
Answer
Answer: B
3. Which React Hook would you prefer to use so as to replace componentWillUnmount() lifecycle method.
functionProductCard(props){return(<divclassName="prod-card"><divclassName="prod-name-contn"><spanclassName="prod-name">{props.eachListItem.title}</span></div><divclassName="btn-contn"><buttonclassName="btn"onClick={function(){props.addToCart(props.eachListItem)}}>
Add to Cart
</button></div></div>);};
C: Both A & B
D: None
Answer
Answer: A
5. Which all Component lifecycle methods are considered legacy which were used to capture changes to props or state?
A: React will mutate every child instead of realizing it can keep the <li>Duke</li> and <li>Villanova</li> subtrees intact.
B: When children have keys, React uses the key to match children in the original tree with children in the subsequent tree.
C: In practice, finding a key is usually not hard. As a last resort, you can pass an item’s index in the array as a key. This can work well if the items are never reordered, but reorders will be slow.