Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Create ViewPropTypes #140

Merged
merged 1 commit into from
Jun 21, 2017
Merged

Conversation

newtonry
Copy link
Contributor

Due to the deprecation of View.propTypes, we are now supposed to use ViewPropTypes imported from react-native. This library doesn't support that yet, so this PR adds ViewPropTypes. It should resolve issues like #139 and #132. In it, I've:

const forceTouchAvailable = false;

const statics = {
AccessibilityComponentType: AccessibilityComponentTypes,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use the property shorthand here.

Copy link
Contributor Author

@newtonry newtonry Jun 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a plurality difference here unfortunately. I made the decision to follow the pattern in react-native (https://github.com/facebook/react-native/blob/master/Libraries/Components/View/ViewAccessibility.js#L59-L64). However, I'm not super insightful about this property in statics, so I'm open to ideas.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah -- missed that. Makes sense!

Copy link
Owner

@RealOrangeOne RealOrangeOne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Looks like there's some issues in the tests on node 4, but these seem to do with dependancy issues outside this PR, so i'm happy to merge as-is.

@RealOrangeOne RealOrangeOne merged commit b8fa4b4 into RealOrangeOne:master Jun 21, 2017
@jcharlet
Copy link

jcharlet commented Jul 5, 2017

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!

@newtonry
Copy link
Contributor Author

newtonry commented Jul 5, 2017

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

@jcharlet
Copy link

jcharlet commented Jul 6, 2017

@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 :) !

@gardner
Copy link

gardner commented Aug 18, 2017

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

@lucascarvalho
Copy link

@gardner same problem here, did you find a solution for this?

@khirakawa
Copy link

@gardner @lucascarvalho You need to build react-native-mock if you install it via npm install --save-dev github:RealOrangeOne/react-native-mock#master

  1. cd node_modules/react-native-mock
  2. Add the following to package.json
"babel": {
  "presets": [
    "airbnb",
    "react-native"
  ]
},
  1. Run npm run build

gabrielrotbart added a commit to gabrielrotbart/react-native-mock that referenced this pull request Feb 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants