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 of morfeo.useTheme method name #142

Closed
mauroerta opened this issue Feb 10, 2022 · 1 comment · Fixed by #143
Closed

Change of morfeo.useTheme method name #142

mauroerta opened this issue Feb 10, 2022 · 1 comment · Fixed by #143
Labels
enhancement New feature or request

Comments

@mauroerta
Copy link
Collaborator

The problem

I think that the useTheme method of morfeo can result ambiguous in a react environment, for example:

const { useTheme } = morfeo;
// Can be confused with the hook `useTheme` of `@morfeo/hook`
useTheme('dark');

Also other problems can occur, for example:

const { useTheme } = morfeo;
if (condition) {
  // this is completely legal, since `useTheme` is not a hook (in this case) so we are not calling
  // an hook conditionally. 
  // but the linter will complain since it will not understand that useTheme is not a hook.
  useTheme('dark');
}

Solution

Instead of useTheme we can rename this method setCurrent, for me it makes sense even because we have a similar method called getCurrent that retrieves the name of the current theme:

const { setCurrent } = morfeo;
// No ambiguity with `useTheme`
setCurrent('dark');

Also. since all the other methods related to the theme contains the suffix theme, we can this about rename not only useTheme but also getCurrent in this way:

  • morfeo.useTheme will become morfeo.setCurrentTheme
  • morfeo.getCurrent will become morfeo.getCurrentTheme
@mauroerta mauroerta added the enhancement New feature or request label Feb 10, 2022
@andreaSimonePorceddu
Copy link
Collaborator

I totally agree.

@mauroerta mauroerta pinned this issue Feb 10, 2022
mauroerta added a commit that referenced this issue Feb 10, 2022
mauroerta added a commit that referenced this issue Feb 10, 2022
@mauroerta mauroerta mentioned this issue Feb 10, 2022
9 tasks
@mauroerta mauroerta unpinned this issue Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants