-
Notifications
You must be signed in to change notification settings - Fork 96
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
Port remaining hooks from react-use
#33
Comments
To be clear - not all hooks will be ported, as for me - i'm against of transfering all |
Definitely! Should we make a list of all the hooks that we don't want ported? Then I can cross them out above. @xobotyi |
@JoeDuncko its hard to say rn, im reviewing the hooks on the go and currently refactoring (the full cycle refactoring, meaning reimplementing them from the scratch) hooks im currently using at my job, as this is easiest way for me, as i have little expertise in other areas. |
we dont have |
Crossed out the "create" hooks, split up all the lines with "and"s. |
Added links to the new |
Thank you so much for starting this repo and leading this huge migration work! 🍻 Just wondering what the reasoning is for not migrating the I should add that I can't just turn all of my utility functions into hooks with |
This issue should now be up to date FYI. |
I can't see the sense of porting |
@xobotyi I was about to do it, but it looks like there is already a |
Updated the list again. |
…oks and check porting approval The aim of this change is to reduce the number of cases where a PR for a new hook is submitted, but the code is rejected, because the hook has no valid use-case or has not been approved for porting from react-use. re #33
The aim of this section is to reduce the number of incidences where a PR for porting a new hook from react-use is submitted and rejected because the hook has no valid use-case or has not been approved for porting re #33
…w hooks (#1060) * docs(New hook PR template): Add section for valid use-case for new hooks, check that hooks ported from react-use are approved for porting * docs(CONTRIBUTING.md): Add a section on porting hooks from react-use The aim of these changes is to reduce the number of cases where a PR for a new hook is submitted, but the code is rejected, because the hook has no valid use-case or has not been approved for porting from react-use. re #33
Ticked off What does everybody think about porting of the following hooks:
|
agreed on all of them |
For useTween, I would like to make a suggestion to the API. It would be helpful if it can return a start function to grant control over when to start the tweening process. const [t, start, stop, restart] = useTween() |
@JoeDuncko can i work on useScrolling, only the test is not done |
Sure! |
@JoeDuncko I would like to work on |
Sure! |
@JoeDuncko dang it! we already have a queue hook, but it is missing from hooks listing🤦♂️ |
@xobotyi Ah crap, I can knock that out if no one else does tomorrow. |
@JoeDuncko @xobotyi |
@JoeDuncko @xobotyi type SpeechOptions = {
lang: string;
voice?: SpeechSynthesisVoice;
rate: number;
pitch: number;
volume: number;
};
export type VoiceInfo = Pick<SpeechSynthesisVoice, 'lang' | 'name'>;
export type ISpeechState = SpeechOptions & {
isPlaying: boolean;
status: string;
voiceInfo: VoiceInfo;
};
enum Status {
init,
play,
pause,
end,
}
const useSpeech = (text: string, options: ISpeechOptions): ISpeechState Same as we have in |
@malavshah9 sold! |
@xobotyi I wanted to work and port below mentioned hooks:
|
@malavshah9 it would be way better if youll help with tests migration so we can switch towards react 18 I will update that PR so it is containing only tests changes without, and after that youll be able to migrate tests |
@xobotyi I would love to do that. Should I start migrating that for each hooks and giving you separate PR? |
Our goal with
@react-hookz/web
is to give the react community a general-purpose React hooks library built with care.We'd like to port the remaining hooks from react-use (the project
@react-hookz/web
grew out of) while keeping in mind our tenants:Hooks to port
Sensors
useHash — tracks location hash value.(No plans to implement. Instead, use one the various routing libraries available.)useKey — track keys.(Implemented as useKeyboardEvent)useKeyPress — track keys.(Implemented as useKeyboardEvent)useKeyboardJs — track keys.(Implemented as useKeyboardEvent)useKeyPressEvent — track keys.(Implemented as useKeyboardEvent)useLocation — tracks page navigation bar location state.(No plans to implement. Instead, use one the various routing libraries available.)useSearchParam — tracks page navigation bar location state.(No plans to implement. Instead, use one the various routing libraries available.)useSize — tracks an HTML element's dimensions.(UseuseWindowSize
instead)createBreakpoint — tracks innerWidth(Not planning to implement)UI
Animations
useInterval and useHarmonicIntervalFn — re-renders component on a set interval using setInterval.(Implemented asuseIntervalEffect
).useTimeout — re-renders component after a timeout.(Can be composed from other hooks, see migration guide).useTimeoutFn — calls given function after a timeout.(Implemented asuseTimeoutEffect
).Side-effects
useBeforeUnload — shows browser alert when user try to reload or close the page.(No plans to implement, address migration guide for workaround)useCopyToClipboard — copies text to clipboard.(no plans to implement - use browser's API instead)useFavicon — sets favicon of the page.(Hooks that modify the element will not be implemented).useThrottleFn — throttles a function.useTitle — sets title of the page.(Hooks that modify the element will not be implemented).Lifecycles
useEffectOnce — a modified useEffect hook that only runs once.(it's just an alias foruseMountEffect
)useLifecycles — calls mount and unmount callbacks.(no sense to port, has almost no benefit comparing touseEffect
)useUnmountPromise — track if component is mounted.(No plans to implement).usePromise — resolves promise only while component is mounted.(No plans to implement)useLogger — logs in console as component goes through life-cycles.(Implemented as useLifecycleLoggerState
createMemo — factory of memoized hooks.(Not planning to implement)createReducer — factory of reducer hooks with custom middleware.(Not planning to implement)createReducerContext — factory of hooks for a sharing state between components.(Not planning to implement)createStateContext — factory of hooks for a sharing state between components.(Not planning to implement)useDefault — returns the default value when state is null or undefined.(No plans to implement. Use useMediatedState instead).useGetSet — returns state getter get() instead of raw state.(No plans to implement)useGetSetState — as if useGetSet and useSetState had a baby.(No plans to implement)useSetState — creates setState method which works like this.setState.(No plans to implement)useNumber — tracks state of a number.(Implemented as useCounter)useUpsert — tracks state of an array.(UseuseList
instead.)useRendersCount — count component renders.(Implemented asuseRenderCount
).createGlobalState — cross component shared state.(Not planning to implement)useMethods — neat alternative to useReducer.(No plans to implement)Miscellaneous
Join our community!
Have a question? Create a discussion on GitHub or join our Discord community.
Interested in contributing code? Check out our contribution guide. We are excited to see your pull request!
The text was updated successfully, but these errors were encountered: