Closed newtonry closed 7 years ago
Hi guys, sorry for the newbie question but how to load the master branch of react-native-mock in my project?
I tried
npm install --save github:RealOrangeOne/react-native-mock#master
cd nodes_modules/react-native-mock
npm install
rm -rf nodes_modules
but it must be wrong because I get this issue after:
● Test suite failed to run
TypeError: Cannot read property 'shape' of undefined at Object.<anonymous> (node_modules/react-native-mock/build/propTypes/EdgeInsetsPropType.js:8:33) at Object.<anonymous> (node_modules/react-native-mock/build/propTypes/ViewPropTypes.js:6:25) at Object.<anonymous> (node_modules/react-native-mock/build/components/View.js:7:20)
Thanks!
@jcharlet if I understand correctly you shouldn't be rm -rf nodes_modules
in the nodes_modules/react-native-mock
directory. Those are the dependencies that react-native-mock
has. By deleting them, React
(https://github.com/RealOrangeOne/react-native-mock/blob/master/src/propTypes/EdgeInsetsPropType.js#L4) is probably becoming undefined
and hence, PropTypes.shape
will not work.
Try it again without deleting the node_modules
directory after installing the modules.
@newtonry great thanks! I had conflicts between react-native module of my project and react-native-mock (they use different versions). so I simply removed react-native from react-native-mock/node_modules (but still kept the rest) and it now works :) !
I am running into issues with this PR as well.
After running:
npm install --save-dev github:RealOrangeOne/react-native-mock#master
Then npm run ava
Looks like the package.json
and mock.js
expect a file to be present: Error: Cannot find module './build/react-native'
$ grep -H build/react-native node_modules/react-native-mock/*
node_modules/react-native-mock/mock.js:const ReactNativeMock = require('./build/react-native');
node_modules/react-native-mock/package.json: "main": "build/react-native.js",
but there is no build/
directory relative to the files:
$ls node_modules/react-native-mock
LICENSE README.md mock.js package.json src
@gardner same problem here, did you find a solution for this?
@gardner @lucascarvalho You need to build react-native-mock
if you install it via npm install --save-dev github:RealOrangeOne/react-native-mock#master
cd node_modules/react-native-mock
Add the following to package.json
"babel": {
"presets": [
"airbnb",
"react-native"
]
},
Run npm run build
Due to the deprecation of
View.propTypes
, we are now supposed to useViewPropTypes
imported fromreact-native
. This library doesn't support that yet, so this PR addsViewPropTypes
. It should resolve issues like https://github.com/RealOrangeOne/react-native-mock/issues/139 and https://github.com/RealOrangeOne/react-native-mock/issues/132. In it, I've:propTypes
from being defined inView.js
ViewPropTypes
which matches https://github.com/facebook/react-native/blob/master/Libraries/Components/View/ViewPropTypes.js minusTVViewPropTypes
AccessibilityTraits
andAccessibilityComponentTypes
to aViewAccessibility
file. Let me know if this should go somewhere else.ViewPropTypes