Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

143
Visualizações
React CSS transition not working at all with Typescript

In todo react app with typescript CSS transition is not working at all

I am curretly trying to add at least enter/exit animations for each to do, if i will get this working, rest should be easier

Also using Basic redux with todolist here

Here is my code

Todo:
const Todo: React.FC<Props> = forwardRef((props) => {
    useEffect(() => {
        console.log(props.ref);
    });
    return (
        <CSSTransition<undefined>
            addEndListener={(node: HTMLElement, done: () => void) => {
                node.addEventListener("transitionend", done, false);
            }}
            className="Todo"
            timeout={1000}
            appear={true}
        >
            <div>
                <span>{props.index + 1}</span>
                <span>{props.todo.name}</span>
                <span>{props.todo.details}</span>
                {props.todo.complete ? (
                    <span>Done</span>
                ) : (
                    <span>Active</span>
                )}
                <button onClick={() => props.Delete(props.todo.id)}>
                    Delete
                </button>
                <button onClick={() => props.Done(props.todo.id)}>
                    Done
                </button>
            </div>
        </CSSTransition>
    );
});

css:

.TodoContainer {
  width: 100%;
  position: relative;
  padding: 0;
}

.TodoNew {
  width: 100%;
  height: 50px;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  margin-bottom: 10px;
  border-bottom-color: #AEAEAE;
  opacity: 0.3;
  border-bottom-width: 1px;
  outline: none;
  padding-bottom: 0;
}

.Todo {
  background-color: #fff;
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 50px;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
}

.Todo-appear {
  opacity: 0;
}

.Todo-appear-active {
  opacity: 1;
  transition: opacity 1000ms;
}

.Todo-enter {
  opacity: 0;
}

.Todo-enter-active {
  opacity: 1;
  transition: opacity 200ms;
}

.Todo-exit {
  opacity: 1;
}

.Todo-exit-active {
  opacity: 0;
  transition: opacity 200ms;
}

Parent component:

<TransitionGroup component="div" className="TodoContainer">
{
    props.todoList ?
    props.todoList.map((todo, index) => {
        return(
        <>
            <Todo todo={todo} key={todo.id} index={index} Delete={props.DeleteTodo}                                    Done={props.DoneTodo} />
        </>
        )
                                
                            })
                            :
                    <></>
                       }
         </TransitionGroup>

StackOverflow broke my indentation here ((

How to be done here??

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda