react-hookz / web

React hooks done right, for browser and SSR.
https://react-hookz.github.io/web/
MIT License
1.92k stars 92 forks source link

Port remaining hooks from `react-use` #33

Open JoeDuncko opened 3 years ago

JoeDuncko commented 3 years ago

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

UI

Animations

Side-effects

Lifecycles

State

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!

xobotyi commented 1 year ago

@JoeDuncko dang it! we already have a queue hook, but it is missing from hooks listing🤦‍♂️

JoeDuncko commented 1 year ago

@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.

malavshah9 commented 1 year ago

@JoeDuncko @xobotyi I was just looking to work on useCopyToClipboard, but then found this discussion where we have concluded that it is not needed at the moment. Can we remove this from this list also, if we don't want to build it.

malavshah9 commented 1 year ago

@JoeDuncko @xobotyi Moreover, I am looking to work on useSpeech with the following definition, is this fine or do we want to improve here?


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 react-use

xobotyi commented 1 year ago

@malavshah9 sold!

malavshah9 commented 1 year ago

@xobotyi I wanted to work and port below mentioned hooks:

  1. useIdle
  2. useRaf
  3. useGeolocation
  4. useStateList
xobotyi commented 1 year ago

@malavshah9 it would be way better if youll help with tests migration so we can switch towards react 18

https://github.com/react-hookz/web/pull/1377

I will update that PR so it is containing only tests changes without, and after that youll be able to migrate tests

malavshah9 commented 1 year ago

@xobotyi I would love to do that. Should I start migrating that for each hooks and giving you separate PR?