Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

TypeError: renderPager is not a function #523

Closed
zabojad opened this issue May 16, 2018 · 1 comment
Closed

TypeError: renderPager is not a function #523

zabojad opened this issue May 16, 2018 · 1 comment

Comments

@zabojad
Copy link

zabojad commented May 16, 2018

Current behaviour

Getting this at runtime:

Unhandled JS Exception: TypeError: renderPager is not a function

This error is located at:
    in TabViewAnimated

Expected behaviour

Have it working correctly and not crashing

Code sample

I'm using Haxe to generate my application code before letting react digesting it.

Here is the js generated code I have:

var reactnative_tabview_SceneMap = require("react-native-tab-view/src/SceneMap").default;
var reactnative_tabview_TabBar = require("react-native-tab-view/src/TabBar").default;
var reactnative_tabview_TabViewAnimated = require("react-native-tab-view/src/TabViewAnimated").default;

var myproj_view_screen_sessionhome_SessionHomeView = function() { };
myproj_view_screen_sessionhome_SessionHomeView.__name__ = true;
myproj_view_screen_sessionhome_SessionHomeView.render = function(props) {
	var tmp = React.createElement(react_native_component_View,{ },"Items:");
	var tmp1 = { "$$typeof" : $$tre, type : myproj_view_screen_sessionhome_SessionItems, props : { }, key : null, ref : null};
	return React.createElement(react_native_component_View,{ },tmp,tmp1,{ "$$typeof" : $$tre, type : myproj_view_cmp_footer_Footer.render, props : { currentIndex : 2}, key : null, ref : null});
};
var myproj_view_screen_sessionhome_SessionItems = function(p) {
	React_Component.call(this,p);
	this.state = { index : 0, routes : [{ key : "first", title : "First"},{ key : "second", title : "Second"}]};
};
myproj_view_screen_sessionhome_SessionItems.__name__ = true;
myproj_view_screen_sessionhome_SessionItems.__super__ = React_Component;
myproj_view_screen_sessionhome_SessionItems.prototype = $extend(React_Component.prototype,{
	handleIndexChange: function(index) {
		this.setState({ index : index});
	}
	,renderHeader: function(p) {
		return { "$$typeof" : $$tre, type : reactnative_tabview_TabBar, props : Object.assign({ },p,{ style : { backgroundColor : "#f44336"}, labelStyle : { color : "#fff"}}), key : null, ref : null};
	}
	,renderScene: function(args) {
		window.console.log("renderScene",args);
		return reactnative_tabview_SceneMap({ first : myproj_view_screen_sessionhome_SessionItemList, second : myproj_view_screen_sessionhome_SessionItemList});
	}
	,render: function() {
		return { "$$typeof" : $$tre, type : reactnative_tabview_TabViewAnimated, props : { navigationState : this.state, renderHeader : $bind(this,this.renderHeader), style : { flex : 1, height : 150, width : 250}, renderScene : $bind(this,this.renderScene), onIndexChange : $bind(this,this.handleIndexChange), initialLayout : myproj_view_screen_sessionhome_SessionItems.initialLayout}, key : null, ref : null};
	}
	,__class__: myproj_view_screen_sessionhome_SessionItems
});
var myproj_view_screen_sessionhome_SessionItemList = function() { };
myproj_view_screen_sessionhome_SessionItemList.__name__ = true;
myproj_view_screen_sessionhome_SessionItemList.render = function(p) {
	return React.createElement(react_native_component_View,{ style : { flex : 1, height : 150, width : 250, backgroundColor : "red"}},"TODO");
};

Screenshots (if applicable)

n/a

What have you tried

I've tried requiring the components like this but I'm having the same issue:

var reactnative_tabview_SceneMap = require("react-native-tab-view").SceneMap;
var reactnative_tabview_TabBar = require("react-native-tab-view").TabBar;
var reactnative_tabview_TabViewAnimated = require("react-native-tab-view").TabViewAnimated;

Your Environment

software version
ios or android iOS simulator
react-native 0.54.2
react-native-tab-view I've tried 0.0.74, 0.0.77 and 0.0.78
node v6.9.4
npm or yarn 4.6.1
@zabojad
Copy link
Author

zabojad commented May 16, 2018

OK so I've managed to make it work with this:

var reactnative_tabview_SceneMap = require("react-native-tab-view/src/SceneMap").default;
var reactnative_tabview_TabBar = require("react-native-tab-view/src/TabBar").default;
var reactnative_tabview_TabViewAnimated = require("react-native-tab-view/src/TabViewAnimated").default;

var my_proj_view_screen_sessionhome_FirstRoute = function(props,context) {
	React_Component.call(this,props,context);
};
my_proj_view_screen_sessionhome_FirstRoute.__name__ = true;
my_proj_view_screen_sessionhome_FirstRoute.__super__ = React_Component;
my_proj_view_screen_sessionhome_FirstRoute.prototype = $extend(React_Component.prototype,{
	render: function() {
		return React.createElement(react_native_component_View,{ style : [my_proj_view_screen_sessionhome_SessionItems.styles.scene,my_proj_view_screen_sessionhome_FirstRoute.st]});
	}
	,__class__: my_proj_view_screen_sessionhome_FirstRoute
});
var my_proj_view_screen_sessionhome_SecondRoute = function(props,context) {
	React_Component.call(this,props,context);
};
my_proj_view_screen_sessionhome_SecondRoute.__name__ = true;
my_proj_view_screen_sessionhome_SecondRoute.__super__ = React_Component;
my_proj_view_screen_sessionhome_SecondRoute.prototype = $extend(React_Component.prototype,{
	render: function() {
		return React.createElement(react_native_component_View,{ style : [my_proj_view_screen_sessionhome_SessionItems.styles.scene,my_proj_view_screen_sessionhome_SecondRoute.st]});
	}
	,__class__: my_proj_view_screen_sessionhome_SecondRoute
});

var my_proj_view_screen_sessionhome_SessionItems = function(p) {
	React_Component.call(this,p);
	this.state = { index : 0, routes : [{ key : "first", title : "First"},{ key : "second", title : "Second"}]};
};
my_proj_view_screen_sessionhome_SessionItems.__name__ = true;
my_proj_view_screen_sessionhome_SessionItems.__super__ = React_Component;
my_proj_view_screen_sessionhome_SessionItems.prototype = $extend(React_Component.prototype,{
	handleIndexChange: function(index) {
		this.setState({ index : index});
	}
	,getLabelText: function(sc) {
		window.console.log("getLabelText",sc);
		return "toto";
	}
	,renderHeader: function(p) {
		return React.createElement(reactnative_tabview_TabBar,Object.assign({ },p,{ style : my_proj_view_screen_sessionhome_SessionItems.styles.header}));
	}
	,render: function() {
		var initialLayout = { height : 0, width : react_native_api_Dimensions.get("window").width};
		var renderScene = reactnative_tabview_SceneMap({ first : my_proj_view_screen_sessionhome_FirstRoute, second : my_proj_view_screen_sessionhome_SecondRoute});
		return React.createElement(reactnative_tabview_TabViewAnimated,{ navigationState : this.state, renderHeader : $bind(this,this.renderHeader), style : [my_proj_view_screen_sessionhome_SessionItems.styles.root], renderScene : renderScene, onIndexChange : $bind(this,this.handleIndexChange), initialLayout : initialLayout});
	}
	,__class__: my_proj_view_screen_sessionhome_SessionItems
});

So it seems that react-native-tab-view do not like inline ReactElements. If it's the case, it is a bug and should be addressed so...

@zabojad zabojad closed this as completed May 16, 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

No branches or pull requests

1 participant