Open gregfenton opened 4 years ago
One note: in each of the examples' package.json
, the dependency for react-native-responsive-screen
points to a version using yalc because the examples requires a version that isn't published yet (it is part of this PR...circular dependency).
To engage with this version, you can follow these steps:
git clone https://github.com/marudy/react-native-responsive-screen.git
cd react-native-responsive-screen
git fetch origin pull/83/head
git checkout -b pullrequest FETCH_HEAD
npm install yalc
(or yarn add yalc
)yalc publish
Now you are ready to run any of the examples. Let's try the new Hook-based one:
cd examples/responsive-screen-orientation-change-with-hooks
npm install
yalc add react-native-responsive-screen
yalc update react-native-responsive-screen
<< not sure why this was necessary, but running failed to find the NPM without itnpm run ios
If not obvious (it is quite a large PR), the likely controversial parts of this are:
Move to use of Expo. The thinking here is that if it works with Expo, then it works with React Native. The converse is not necessarily true. And with Expo there are far less "moving parts" for simply getting up and running.
The method signature of listenOrientationChange
has changed, forcing the developer to identify whether they are passing in a class component's "this", or a functional component's "set" method from a call to useState()
-- though the code does not enforce that function be a useState()
function, so you could pass in any type of function.
Can I use your fork in a production?
It is warranted for its full price 🙂
I am using it in production.
@gregfenton you could as well add hook support to currentOrientation, I can help if you'd like
In trying to get a hooks example going, I ended up doing a fair amount of work I hope others might benefit from:
index.js
to support boththis
and auseState()
set functioncurrentOrientation()
useState
&useEffect
stylized-components
- as of v5 it requires units to be specified on many styles