setListing((prevState: any) => { const todos = [...prevState.listingTodos] const newTodos = todos.map(todo => { return { ...todo, expanded: todo.tabValue === todoValue, } }) return { ...prevState, listingLoading: false, listingTodos: newTodos, } }) | |
const array = [ [ ['Shoaib Mehedi'] ] ] | |
array.forEach((firstArr) =>{ | |
firstArr.forEach((secondArr) => { | |
secondArr.forEach((element) => { | |
console.log(element); | |
}) | |
}) | |
}) | |
// good practice | |
const array = [ [ ['Shoaib Mehedi'] ] ] | |
const getValuesOfNestedArray = (element) => { | |
if(Array.isArray(element)){ | |
return getValuesOfNestedArray(element[0]) | |
} | |
return element | |
} | |
getValuesOfNestedArray(array) |
const {role} = user const components = { ADMIN: AdminUser, EMPLOYEE: EmployeeUser, USER: NormalUser}; const Component = components[role]; return <Componenent />; | |
Don't Define a Function Inside Render
return ( | |||||||||||||||
<button onClick={() => dispatch(ACTION_TO_SEND_DATA)}> // NOTICE HERE | |||||||||||||||
This is a bad example | |||||||||||||||
</button> | |||||||||||||||
)
|
Comments
Post a Comment