streamich / react-use

React Hooks — 👍
http://streamich.github.io/react-use
The Unlicense
41.92k stars 3.16k forks source link

React-Native support #829

Open Sir-hennihau opened 4 years ago

Sir-hennihau commented 4 years ago

Is React-Native supported? It does not seem so at the moment.


ScreamZ commented 4 years ago

+1

xobotyi commented 4 years ago

AFAIK none of collaborators use RN, so we dont know anything about that. If you are ready to make hooks RN-ready - we will be glad to see your PR.

ScreamZ commented 4 years ago

It's only a matter to isolate browser API and expose module as UMD

italomlp commented 4 years ago

Is there someone working on it? If not, I want to try :D

streamich commented 4 years ago

@italomlp it's all yours!

sangdth commented 4 years ago

I've tried to use useTimeoutFn and it complains about global window and/or document.

davidsonsns commented 4 years ago

@sangdth to fix it temporarily you can import like this:

import useTimeoutFn from 'react-use/lib/useTimeoutFn';

ScreamZ commented 4 years ago

@davidsonsns Does it work for useThrottleFn ?

davidsonsns commented 4 years ago

Yeah @ScreamZ ! Tested right now and it's working. import useThrottleFn from 'react-use/lib/useThrottleFn';

sangdth commented 4 years ago

@sangdth to fix it temporarily you can import like this:

import useTimeoutFn from 'react-use/lib/useTimeoutFn';

I confirm this method works. Hope we will have better way to improve this.

streamich commented 4 years ago

@sangdth Any ideas how it could be improved?

sangdth commented 4 years ago

For now, in my project, in order to avoid:

import useOne from 'react-use/lib/useOne';
import useTwo from 'react-use/lib/useTwo';
...

I have to make another helper, to

export {
    useOne,
    useTwo,
    ...
} from './customHooks';

I would like to import like that directly from react-use.

LRNZ09 commented 4 years ago

This would be a really nice-to-have!

chancesmith commented 4 years ago

+1

husterk commented 3 years ago

Has there been any update on this issue? It would be wonderful to not have to manually import each and every function from the react-use/lib/* directories.

dzcpy commented 3 years ago

+1

y-nk commented 3 years ago

@italomlp as there's not any progress should we consider that you moved on? should i make a PR?

francois-pasquier commented 3 years ago

@italomlp as there's not any progress should we consider that you moved on? should i make a PR?

I think you can assume nobody has ever fixed this.

dzcpy commented 3 years ago

Switched to ahooks and it works fine

hugobarragon commented 3 years ago

import useThrottleFn from 'react-use/lib/useThrottleFn';

hi guys, this lib works, just have to use like this, or implement the treeshaking, if you do not implement de tree shaking it will compile all modules and there are some that probably only work on web, its mutch easier to post here the methods that are not currently wokring on react native

I only use effect methods like useMount, useUpdateEffect... so for me works great

lukasa1993 commented 2 years ago

react-dom peer dependency isn't also necessary for react-native any idea how to avoid it ?