Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ViewPager.js: Unable to resolve module StaticRenderer #5

Closed
sulliwane opened this issue Nov 3, 2015 · 16 comments
Closed

ViewPager.js: Unable to resolve module StaticRenderer #5

sulliwane opened this issue Nov 3, 2015 · 16 comments

Comments

@sulliwane
Copy link

Hello, thank you for this useful component. I have a problem since upgrading to RN-v0.14.0-rc (I'm not sure it's related) :
Error while loading: Unable to resolve module StaticRenderer from /Users/yosemit/Documents/Chat_Test/node_modules/react-native-viewpager/ViewPager.js: Invalid directory /Users/node_modules/StaticRenderer

Any idea what is the cause of this error? Thanks

@race604
Copy link
Owner

race604 commented Nov 4, 2015

I just tested this on RN-v0.14.0-rc, it works fine on Android, but break on iOS. I'll check this.

@sulliwane
Copy link
Author

Actually I also have the same error show up when packaging for Android, see below:

[1:14:23 PM] <START> find dependencies
Unable to resolve module StaticRenderer from /home/sul/Documents/Chat_App/node_modules/react-native-viewpager/ViewPager.js
Unable to resolve module invariant from /home/sul/Documents/Chat_App/node_modules/react-native-viewpager/ViewPagerDataSource.js
Unable to resolve module isEmpty from /home/sul/Documents/Chat_App/node_modules/react-native-viewpager/ViewPagerDataSource.js
Unable to resolve module warning from /home/sul/Documents/Chat_App/node_modules/react-native-viewpager/ViewPagerDataSource.js
[1:14:23 PM] <END>   find dependencies (147ms)
[1:14:23 PM] <START> transform
transforming [========================================] 100% 403/404[1:14:23 PM]

I use npm@3.3.10

Thanks a lot for your help.

@race604
Copy link
Owner

race604 commented Nov 4, 2015

I think 0.14.0-rc is not well tested, there is the same problem facebook/react-native#3817

I'll check this is issue when 0.14.0 released.

@sulliwane
Copy link
Author

Indeed, the StaticRenderer problem can be solved by using destructuring assignment (instead of direct import, which is not recommended):


var React = require('react-native');
var {
  Dimensions,
  Text,
  View,
  TouchableOpacity,
  PanResponder,
  Animated,
  PropTypes,
  StyleSheet,
  StaticRenderer,
} = React

But then there is problem with this 3 import:

var invariant = require('invariant');
var isEmpty = require('isEmpty');
var warning = require('warning');

It looks like invariant and warning are both npm packages, so i installed them. And I replace isEmpty by if (arr.length == 0) {, but still I get this error:

screenshot from 2015-11-04 16 08 56

Thanks :)

@race604
Copy link
Owner

race604 commented Nov 4, 2015

This is the same problem: can't find the StaticRenderer element. We can remove the reference of StaticRenderer:

  _getPage(pageIdx: number) {
    var dataSource = this.props.dataSource;
    var pageID = dataSource.pageIdentities[pageIdx];
    return this.props.renderPage(
      dataSource.getPageData(pageIdx),
      pageID
    );
    // return (
    //   <StaticRenderer
    //     key={'p_' + pageID}
    //     shouldUpdate={true}
    //     render={this.props.renderPage.bind(
    //       null,
    //       dataSource.getPageData(pageIdx),
    //       pageID
    //     )}
    //   />
    // );
  },

@py110
Copy link

py110 commented Nov 6, 2015

0.14 same problem

@gunters63
Copy link

Removing the reference of StaticRenderer only helps partially.
ViewPagerDataSource requires invariant, isEmpty and warning modules which were pulled in automatically before (0.13), not anymore now.

@sulliwane
Copy link
Author

Packager for Android, same problem (0.14.0 here):
androidbugpager

Unable to resolve module invariant from node_modules/react-native-viewpager/ViewPagerDataSource.js
Unable to resolve module isEmpty from node_modules/react-native-viewpager/ViewPagerDataSource.js
Unable to resolve module warning from node_modules/react-native-viewpager/ViewPagerDataSource.js

I'll keep you updated if I find a dirty fix :)

@sulliwane
Copy link
Author

npm install invariant
npm install warning

in ViewPagerDataSource.js Replace isEmpty(array) by arr.length === 0

and finally in ViewPager.js Move StaticRenderer into:

var {
  StaticRenderer,
} = React;

Then all the warnings disappear, but ...here is the remaining error:

staticrenderer
Invariant violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. Check the render method of 'ViewPager'.

@alvinwoon
Copy link

on latest iOS device and simulator as well. RN 0.14.1

@drosko
Copy link

drosko commented Nov 9, 2015

I get the same error about the Invariant violation, expected a string, on iOS, even after fixing the things above.

@paulgessinger
Copy link

The invariant error is caused by StaticRenderer being undefined when extracting it from react.

Try requiring it from "react-native/Libraries/Components/StaticRenderer", that worked for me. (Having other problems now though.

@sulliwane
Copy link
Author

Thanks paulgessinger, it worked for me :)

@leeight
Copy link

leeight commented Nov 13, 2015

+1

race604 added a commit that referenced this issue Nov 17, 2015
Fix #5 and remove invariant in ViewPagerDataSource.js
@alvinwoon
Copy link

Thanks for the fix and merge. Will it be pushed out via new npm version?

@race604
Copy link
Owner

race604 commented Nov 17, 2015

Thank you for this PR, I'll release a new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants