Jump to content
Search Community

Kimbly

Members
  • Posts

    3
  • Joined

  • Last visited

Posts posted by Kimbly

  1. Hi, I just begin use this tools but I face the problem that if I have code like this

     const items = React.useRef([]);
    const [arr, setArr] = React.useState([1,2,3])
    
    
    React.useEffect(() => {
       items.current = items.current.slice(0, arr.length);
          const lastItem = items.current[items.current.length - 1];
    
          tl.from(lastItem, 0.6, {
            x: -500,
            ease: Power3.easeInOut,
            autoAlpha: 0,
          });
    })
    
    function addNewEl() {
      arr.push(4)
    	setArr(arr)
    }
    
    arr.map((n, i) => {
      return (
    	<div ref={el => selectedEl[i] = el}>{n}</div>
      )
    })
    <button onClick={addNewEl}>Add</button>

    the problem is when I click add button the element is show before animate like a flashing please help me. Thanks

×
×
  • Create New...