Skip to main content

Command Palette

Search for a command to run...

Rerender a component using useEffect ?

Published
1 min read
S

I love learning about technology and sharing that with others

hello everyone i know no one is reading my blogposts this is just for my own documentation so that I can refer to this when I really need this .

so here we are rerendering the component once there is update in the redux state ## so once the state is updated we are rerendering the component

  • Background :

once we are adding the milestones we want that the new contract page should reload the component that is milestones and not the complete page that is so cool that we can rerender the part of the page

screenshot_11.png

  const newcontractReducer = useSelector((state) => state.newcontractReducer)
  const dispatch = useDispatch()

  const [storedMilestones, setMilestoneDrop] = useState(
    newcontractReducer.milestones
  )

  //so now what will happen this component will rerender once we the state is updated and new value is stored in that
  useEffect(() => {
    setMilestoneDrop(newcontractReducer.milestones)
  }, [newcontractReducer])
82 views

More from this blog

H

hashcodehub

271 posts

Consistent, Passionate and Organized :)