Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change setTheme type to React.Dispatch<React.SetStateAction<string>>. #178

Closed
wants to merge 8 commits into from

Conversation

yxshv
Copy link

@yxshv yxshv commented May 6, 2023

The setTheme() function in useTheme() hook, Had a argument of type string which changed the setThemeState with the value passed in. But you couldn't send a function through setTheme() .

So, I have updated the setTheme() to support functions, through which previous values can be accessed and the state can be changed accordingly.


And I also, removed the yarn prefix in test:e2e command. Its not required and now it can be run with any package manager

@vercel
Copy link

vercel bot commented May 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-themes-basic ❌ Failed (Inspect) Jun 22, 2023 0:49am
next-themes-tailwind ❌ Failed (Inspect) Jun 22, 2023 0:49am

@yxshv
Copy link
Author

yxshv commented Jun 18, 2023

its been a month and no response :(

@pacocoursey
Copy link
Owner

@yxshv This is a very messy PR.

Keep your PRs to a single topic, in this case only include the setTheme changes. Please remove all code formatting and unrelated script changes. Remove the pnpm lockfile. Remove the random async IIFE.

Happy to review again when it's more focused and valuable.

@yxshv
Copy link
Author

yxshv commented Jun 21, 2023

✔️ removed pnpm-lock.yaml
✔️ undone scripts changes
✔️ removed formattings
✔️ removed asynchronous function

src/index.tsx Outdated Show resolved Hide resolved
src/index.tsx Outdated Show resolved Hide resolved
src/index.tsx Outdated Show resolved Hide resolved
src/index.tsx Outdated Show resolved Hide resolved
Co-authored-by: Dimitri POSTOLOV <en3m@ya.ru>
@yxshv
Copy link
Author

yxshv commented Jul 3, 2023

anything else?

pacocoursey added a commit that referenced this pull request Aug 18, 2023
* port pr 178

* fix up logic
pacocoursey added a commit that referenced this pull request Aug 28, 2023
* add license file (#119)

* Fix README hydration ThemeSwitcher example (#120)

Using `resolvedTheme` will cause the select to show `light` or `dark` when `system` is selected rather than `system` as expected.

Co-authored-by: Paco <34928425+pacocoursey@users.noreply.github.com>

* Update documentation around `defaultTheme` (#130)

The previous documentation referred to using `<ThemeProvider defaultTheme="system">`, but this is no longer necessary

* Memoize ThemeContext.Provider value (#135)

Every time <Theme /> renders a new object is constructed and passed to ThemeContext.Provider. This guarantees that regardless of what inputs changed the Context will be propagated. This is particularly harmful when React is doing hydration because if an unhydrated Suspense boudnary exists in the sub-tree of the Provider it will fall back to client rendering regardless of whether the context is an actual dependency for that Suspense boundary.

This commit adds memoization so the value only changes if one of it's inputs change
To make this memoization effective the default argument for `themes` needed to be statically extracted (it constructs a new array on each function invocation otherwise)

* docs: link npm-version badge to npm package-site (#136)

* Update README with instructions for Next.js 13 appDir (#168)

Update README.md

* make `next-themes` react agnostic (#186)

* tooling: add monorepo and update playwright tests (#196)

* chore: add .nvmrc

* chore: convert intor a turbo based monorepo (yarn workspaces)

* chore: start refactoring playwright tests

* chore: add missing scripts to 'example' package and update playwright config accordingly

* fix(example/tailwind): use class-attribute

* chore(actions): update node version and bump setup-node to v2

* chore: move license to repository-root

* Update README with note for HTML class attribute (#192)

* Port #178 (#200)

* port pr 178

* fix up logic

* fix: add explicit undefined type to support exactOptionalPropertyTypes option (Port #177) (#201)

add explicit undefined

* Convert to pnpm monorepo, fix Vercel builds, improve test caching, lint (#202)

* cleanup package.json files

* prettier

* move tests to test/

* empty commit for vercel build

* empty commit for vercel build

* rename root package.json

* upgrade next.js and react in examples

* switch to pnpm monorepo, upgrade deps

* update github actions to use pnpm, add to packageManager

* use workspace dep

* update workflows to install pnpm

* back to npx

* many changes…

* empty commit for vercel build

* empty commit for vercel build

* empty commit for vercel build

* idk

* revert link changes, ready to merge

* chore: add @types/node & @types/jest to root to ensure IDE correctly lints jest globals

* chore: fix remaining merge-issues

* chore(types): improve comend for UseThemeProps.theme

* chore: fix merge-issue that caused forcedTheme to not be returned as resolvedTheme

* chore: cleanup README

---------

Co-authored-by: Paco <34928425+pacocoursey@users.noreply.github.com>
Co-authored-by: Max Leiter <mleiter@usc.edu>
Co-authored-by: Bruno Crosier <bruno.crosier@gmail.com>
Co-authored-by: Josh Story <josh.c.story@gmail.com>
Co-authored-by: Ian Jones <witspr@gmail.com>
Co-authored-by: Dimitri POSTOLOV <en3m@ya.ru>
Co-authored-by: Amr Hassaballah <hassaballah.amr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants