Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

useMountedState always returns false

Abierto
#2,598 1 comentario 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
react, typescript
Área
frontend

Línea de trabajo

Start with the useMountedState entry point and run the supplied ThemeToggler example. Confirm whether the hook remains false after mounting, then collect the missing React and react-use versions and create a minimal reproduction. Done means the reported behavior and expected mounted-state result are clear enough for maintainers to investigate.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

What is the current behavior?
this always returns false, im doing something wrong ?

'use client';
import React from 'react';
import { useTheme } from 'next-themes';
import { Moon, Sun } from 'lucide-react';
import { Button } from './ui/button';
import { useMountedState } from 'react-use';

export const ThemeToggler = () => {
  const { setTheme, theme } = useTheme();
  const isMounted = useMountedState();

  const isDark = theme === 'dark';

  const Icon = isDark ? Moon : Sun;

  const toggleTheme = () => {
    setTheme(isDark ? 'light' : 'dark');
  };

  // isMounted() is always false here
  if (!isMounted()) return null;

  return (
    <Button size={'icon'} variant={'ghost'} onClick={toggleTheme}>
      <Icon size={24} />
    </Button>
  );
};

Steps to reproduce it and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have extra dependencies other than react-use. Paste the link to your JSFiddle or CodeSandbox example below:

What is the expected behavior?

A little about versions:

  • OS:
  • Browser (vendor and version):
  • React:
  • react-use:
  • Did this worked in the previous package version?
Lenguaje dominante
TypeScript
Estrellas
44k
Forks
3.3k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de streamich/react-use

Todos los issues de streamich/react-use

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.