React Native trying to change the required image based on title - reactjs

what I am trying to do is create a dynamic function to change the required image based on what the title is.
I have tried if statements with no success, though i am still new to react native, and i believe switch cases are hard if not possible in this case, but i have left it up there to help show my point.
What I wanted to do is the title of the tab that is passed in and see if its matched with one of the three, if it is, then i set the required image to a var icon and put that into a return image.
it will come back with no errors, but no images, any ideas are appreciated.
import React from 'react';
import styles from './styling/style.js';
import {StyleSheet, Text, Image, View} from 'react-native';
import {Router, Scene } from 'react-native-router-flux';
import Homepage from './homepage.js';
import Workout from './workouts';
import Settings from './settings';
const TabIcon = ({ selected, title}) => {
switch ({title}) {
case Homepage:
var icon = require("./images/tabHomePageIcon.png");
break;
case Workout:
var icon = require("./images/tabWorkoutIcon.png");
break;
case Settings:
var icon = require("./images/tabSettingIcon.png");
break;
}
return (
<View>
<Image source={icon}></Image>
<Text>{title}</Text>
</View>
);
};
const UniversalTitle = ({selected, title}) => {
return (
<Text style={styles.text}>
Ultimate Fitness Tracker {'\n'}
<Text style={styles.textBody}>The most comprehensive tracker available!
</Text>
</Text>
)
};
export default class Index extends React.Component {
render() {
return (
<Router>
<Scene key='root'>
<Scene key='tabbar' tabs tabBarStyle={styles.footer}>
<Scene key='tabHome' title='Homepage' titleStyle={styles.text} icon={TabIcon}>
<Scene key='pageOne' navigationBarStyle={styles.heading} component={Homepage} renderTitle={UniversalTitle} initial />
</Scene>
<Scene key='tabWorkout' titleStyle={styles.text} title='Workout' icon={TabIcon}>
<Scene key='pageTwo' component={Workout} navigationBarStyle={styles.heading} renderTitle={UniversalTitle} />
</Scene>
<Scene key='tabSettings' titleStyle={styles.text} title='Setting' icon={TabIcon}>
<Scene key='pageThree' component={Settings} navigationBarStyle={styles.heading} renderTitle={UniversalTitle} />
</Scene>
</Scene>
</Scene>
</Router>
)
}
}

In TabIcon Component, you have written
switch ({title})
It should be
switch (title)
and declare variable icon before switch statement.
Try this.
const TabIcon = ({ selected, title}) => {
let icon
switch (title) {
case Homepage:
icon = require("./images/tabHomePageIcon.png");
break;
case Workout:
icon = require("./images/tabWorkoutIcon.png");
break;
case Settings:
icon = require("./images/tabSettingIcon.png");
break;
}
return (
<View>
{icon && <Image source={icon}></Image>}
<Text>{title}</Text>
</View>
);
};
Hope, it solves your problem.

Related

Get my background video and image to change depending on what page(route) you are on

I am trying to get it so depending on which page you are on the background image and video will display itself. Each page has a different image, video or both. Some are without a video.
I have tried using useEffect but keep getting an infinite render or breaking of hook rules. I have looked this up but am not too sure what I am doing wrong.
I think if I create some custom hooks it should work? But i am not sure how to do this.
Background.js
import React, { useState, useEffect } from "react";
import { useLocation } from "react-router-dom";
import BackgroundObj from "./BackgroundObj";
import BackgroundVideo from "./BackgroundVideo";
import BackgroundImage from "./BackgroundImage";
function Background() {
// state to set pathName to the current route location without the domain
const [pathName, setPathName] = useState("/");
// state to set background image
const [picture, setPicture] = useState();
// state to set background video
const [movie, setMovie] = useState();
// state to deconstruct object depending on what page you are on
const [m, setM] = useState(0);
const ChangeBackground = () => {
// maps json array for background videos and images
const mappedObj = BackgroundObj.map((item) => {
return {
image: item.image,
video: item.video,
};
});
console.log("This is mappedObj speaking, I am a... ", mappedObj);
// using useLocation to get route loaction and re-render effect
const location = useLocation();
// get path name ignoring domain
setPathName(location.pathname);
console.log("the location is: ", location);
console.log("getPath being called, path is: ", pathName);
// statement to find which page you are on and set m for deconstructing the correct video and image
switch (pathName) {
case "/":
setM(0);
console.log(
"This is the switch statement speaking, you are on the home page"
);
break;
case "/activities":
console.log(
"This is the switch statement speaking, you are on the activities page"
);
setM(1);
break;
case "/about":
console.log(
"This is the switch statement speaking, you are on the about page"
);
setM(2);
break;
case "/book":
console.log(
"This is the switch statement speaking, you are on the book page"
);
setM(3);
break;
case "/contact":
console.log(
"This is the switch statement speaking, you are on the contact page"
);
setM(4);
break;
case "/privacy":
console.log(
"This is the switch statement speaking, you are on the privacy page"
);
setM(5);
break;
default:
console.log("m equals", m);
}
// deconstructs mapped object with m, m is based on which page you are on
const { image, video } = mappedObj[m];
console.log(
"This is getMapped speaking, i am deconstructing MappedObj into...",
image,
video
);
console.log("what is m after the switch statement:", m);
// statment to check if page has a video or an image or both
if (image === null) {
setMovie(video);
setPicture("");
} else if (video === null) {
setPicture(image);
setMovie("");
} else {
setMovie(video);
setPicture(image);
}
console.log("movie is set to", movie);
console.log("picture is set to", picture);
};
// useEffect(() => {
// ChangeBackground();
// // statment to check if page has a video or a video or both
// if (image === null) {
// setMovie(video);
// setPicture("");
// } else if (video === null) {
// setPicture(image);
// setMovie("");
// } else {
// setMovie(video);
// setPicture(image);
// }
// console.log("movie is set to", movie);
// console.log("picture is set to", picture);
// }, [ChangeBackground, image, movie, picture, video]);
return (
<div className="fixed h-screen w-screen">
<BackgroundVideo video={movie} />
<BackgroundImage image={picture} />
</div>
);
}
export default Background;
BackgroundImage.js
import React from "react";
// provides image and styling for Background
function BackgroundImage(props) {
// sets prop for calling component in parent
const { image } = props;
// image background as makes div much easier to control
return (
<div
className="flex items-end p-0 z-negative1 h-screen w-screen "
style={{
backgroundImage: `url(${image})`,
backgroundSize: "cover",
backgroundRepeat: "norepeat",
backgroundPosition: "bottom",
}}
></div>
);
}
export default BackgroundImage;
BackgroundVideo.js
import React from "react";
// provides video for Background and styling
function BackgroundVideo(props) {
// sets prop for calling component in parent
const { video } = props;
return (
<video
className="absolute z-negative1 min-h-none min-w-none max-w-5xl sm:max-w-none"
autoPlay
loop
muted
>
<source src={video} type="video/mp4" />
Your browser does not support the video tag
</video>
);
}
export default BackgroundVideo;
BackgroundObj.js
import homeVideo from "../../media/videos/test_video.mp4";
import aboutVideo from "../../media/videos/test_video2.mp4";
import homeImage from "../../media/images/homeSkyline.png";
const BackgroundObj = [
{
key: 0,
page: "/",
image: homeImage,
video: homeVideo,
},
{
key: 1,
page: "/about",
image: "null",
video: aboutVideo,
},
];
export default BackgroundObj;
App.js
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import Home from "./pages/Home";
import Activities from "./pages/Activities";
import About from "./pages/About";
import Contact from "./pages/Contact";
import Book from "./pages/Book";
import Navbar from "./components/Navbar";
import Footer from "./components/Footer";
import Background from "./components/background/Background";
function App() {
return (
<div className="relative bg-night flex flex-col h-screen w-screen justify-between z-1 overflow-x-hidden">
<Router>
<Background />
<Navbar />
<Switch>
<Route path="/" exact component={Home} />
<Route path="/activities" exact component={Activities} />
<Route path="/about" exact component={About} />
<Route path="/book" exact component={Book} />
<Route path="/contact" exact component={Contact} />
</Switch>
<Footer />
</Router>
</div>
);
}
export default App;
I fixed this by just calling the Background component into each page, was repeating code a bit but made it a lot easier!

How to use React Navigation Drawer with Next.js?

I'd like to use the React Navigation v5 (Drawer navigation) with Next.js but I have a question about their integration.
In short: React Navigation (Drawer navigation) based on the React Navigation Screens component.
It conditionally renders the correct Screen.
The problem is: Next.js has it's own routing system based on the Folder structure. eg. each file in /pages folder automatically generates an appropriate route so I can't add these files as a React Navigation Screen (at least I'm not sure it's possible at all)
How to make these tools to work together and save the Next.js SSR feature?
Example of the React Navigation Drawer:
import * as React from 'react';
import { Button, View } from 'react-native';
import { createDrawerNavigator } from '#react-navigation/drawer';
import { NavigationContainer } from '#react-navigation/native';
function HomeScreen({ navigation }) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Button
onPress={() => navigation.navigate('Notifications')}
title="Go to notifications"
/>
</View>
);
}
function NotificationsScreen({ navigation }) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Button onPress={() => navigation.goBack()} title="Go back home" />
</View>
);
}
const Drawer = createDrawerNavigator();
export default function App() {
return (
<NavigationContainer>
<Drawer.Navigator initialRouteName="Home">
<Drawer.Screen name="Home" component={HomeScreen} />
<Drawer.Screen name="Notifications" component={NotificationsScreen} />
</Drawer.Navigator>
</NavigationContainer>
);
}
Thanks for any help!
You should use file based routing system from Nextjs on web and do your own navigation on mobile using React Navigation.
Below is my approach,
// this is how your directory might look like
- pages/
- index.tsx // this is your entry point for web
- about.tsx
App.tsx // this is your entry point for native
// pages/index.tsx
import React from 'react';
import { Text, View } from 'react-native';
const Home: React.FC = () => (
<View>
<Text>Welcome to Expo + Next.js 👋</Text>
</View>
);
export default Home;
// pages/about.tsx
import React from 'react';
import { Text, View } from 'react-native';
const About: React.FC = () => (
<View>
<Text>This is about page!</Text>
</View>
);
export default About;
Define your navigator for native app in App.tsx, it will only work on mobile so it doesn't have to be the same as what you have in pages/ folder. (actually if you only want your app run in browser, you don't need it at all.
Nextjs will handle all the route things, SSR etc... just like a normal Nextjs app when you run it in a browser.
// App.tsx
import React from 'react';
import { NavigationContainer } from '#react-navigation/native';
import { createDrawerNavigator } from '#react-navigation/drawer';
import Home from '../pages/index';
import About from '../pages/about';
const Drawer = createDrawerNavigator();
const App: React.FC = () => (
<NavigationContainer>
<Drawer.Navigator>
<Drawer.Screen name="Home" component={Home} />
<Drawer.Screen name="About" component={About} />
</Drawer.Navigator>
</NavigationContainer>
);
export default App;
The important thing is how should you change routes when you have your navigation on native app but an automatically routing system on web?
There is a package to solve this expo-next-react-navigation, check the documentation for details! Make sure you're using the correct version of this package, if you're using React Navigation 5, you should install expo-next-react-navigation#1.1.6 at this moment.
And here is an example, it should work on both platforms,
import React from 'react';
import { FlatList, Text } from 'react-native';
import { Link } from 'expo-next-react-navigation';
const links = [
{ key: 'home', route: '' },
{ key: 'about', route: 'about' },
];
const Links: React.FC = () => (
<FlatList
data={links}
renderItem={({ item }) => (
<Link routeName={item.route}>
{item.key}
</Link>
)}
/>
);
export default Links;

react native bottom sheet and tab bar

I want to implement a player bar in my custom tab bar like apple music or spotify does.
For TabNavigator I have:
const TabNavigator = createBottomTabNavigator({
HomeStack,
LibraryStack,
},
{
initialRouteName: 'HomeStack',
tabBarComponent: props => <CustomTabBar {...props} />,
tabBarOptions: {
showLabel: false,
}
});
And for my custom TabBar I wanted something like that:
import React from 'react';
import { BottomTabBar } from 'react-navigation';
import BottomSheet from 'reanimated-bottom-sheet'
const CustomTabBar = props => {
return (
<React.Fragment>
<BottomSheet
snapPoints = {[450, 300, 0]}
renderContent = {this.renderInner}
renderHeader = {this.renderHeader}
/>
<BottomTabBar {...props} />
</React.Fragment>
);
};
export default CustomTabBar;
Problem is: the BottomSheet is behind the TabBar and blocks touches on the tabbar, so I cannot switch between tabs anymore. How to deal with this problem?
Kind Regards

React Material UI BottomNavigation component Routing Issue

I'm trying to implement the BottomNavigation Component from Material UI and i have an issue with when the user uses the back and forward buttons of the browser.
The problem is, that the BottomNavigation Component is configured to change page in the the layout when a navigation item button is pressed. What it doesn't do however, is change the selected index of the BottomNavigation items when the browser is used to go back to the previous page.
What im left with is an inconsistent state.
How do i go about changing the selected index of the navigation component when the browser buttons are used?
Here is how the UI looks :-
[
Here is the Root Component :-
import React from 'react'
import {browserHistory, withRouter} from 'react-router';
import {PropTypes} from 'prop-types'
import {connect} from 'react-redux'
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'
import AppBar from 'material-ui/AppBar'
import Paper from 'material-ui/Paper'
import MyBottomNavigation from '../material-ui/MyBottomNavigation'
const style = {
padding: 10,
height: '85vh'
}
class Root extends React.Component {
constructor(props) {
super(props)
this.state = {
bottomNavItemIndex : 0
}
}
render() {
return (
<MuiThemeProvider>
<div>
<AppBar title="Pluralsight Admin"
iconClassNameRight="muidocs-icon-navigation-expand-more"
showMenuIconButton={false}
zDepth={1}
/>
<Paper zDepth={1} style={style}>
{this.props.children}
</Paper>
<MyBottomNavigation/>
</div>
</MuiThemeProvider>
)
}
}
Root.propTypes = {
children: PropTypes.object.isRequired
}
export default Root
And here is the Navigation Component :-
class MyBottomNavigation extends Component {
constructor(props){
super(props)
this.state = {
selectedIndex: 0
}
this.selectBottomNavigationItem = this.selectBottomNavigationItem.bind(this)
}
selectBottomNavigationItem(index){
this.setState({selectedIndex: index})
switch(index) {
case 0:
return browserHistory.push('/')
case 1:
return browserHistory.push('/courses')
case 2:
return browserHistory.push('/authors')
default:
return browserHistory.push('/')
}
}
render() {
return (
<Paper zDepth={1}>
<BottomNavigation selectedIndex={this.state.selectedIndex}>
<BottomNavigationItem
label="Home"
icon={recentsIcon}
onClick={() => this.selectBottomNavigationItem(0)}
/>
<BottomNavigationItem
label="Course"
icon={favoritesIcon}
onClick={() => this.selectBottomNavigationItem(1)}
/>
<BottomNavigationItem
label="Authors"
icon={nearbyIcon}
onClick={() => this.selectBottomNavigationItem(2)}
/>
</BottomNavigation>
</Paper>
)
}
}
export default MyBottomNavigation
Just got an implementation working!
The trick is to make a new navbar component that wraps the Material UI BottomNavigation and exports it with the react-router-dom's withRouter higher order function. Then you can do some fiddling with the current route passed into the props and set the value of the BottomNavigation component based on an array of routes (which route corresponds to which value).
My code works a bit differently than what you posted originally, I'm just going off of the BottomNavigation example here and the example of usage with react-router-dom here.
Here is my implementation:
/src/App.js
import React, {Component} from 'react';
import './App.css';
import {BrowserRouter as Router, Route} from 'react-router-dom';
import PrimaryNav from './components/PrimaryNav';
// Views
import HomeView from './views/HomeView';
class App extends Component {
render() {
return (
<Router>
<div className="app">
<Route path="/" component={HomeView} />
<PrimaryNav />
</div>
</Router>
);
}
}
export default App;
/src/components/PrimaryNav.js
import React, {Component} from 'react';
import {Link, withRouter} from 'react-router-dom';
import BottomNavigation from '#material-ui/core/BottomNavigation';
import BottomNavigationAction from '#material-ui/core/BottomNavigationAction';
import LanguageIcon from '#material-ui/icons/Language';
import GroupIcon from '#material-ui/icons/Group';
import ShoppingBasketIcon from '#material-ui/icons/ShoppingBasket';
import HelpIcon from '#material-ui/icons/Help';
import EmailIcon from '#material-ui/icons/Email';
import './PrimaryNav.css';
class PrimaryNav extends Component {
state = {
value: 0,
pathMap: [
'/panoramas',
'/members',
'/shop',
'/about',
'/subscribe'
]
};
componentWillReceiveProps(newProps) {
const {pathname} = newProps.location;
const {pathMap} = this.state;
const value = pathMap.indexOf(pathname);
if (value > -1) {
this.setState({
value
});
}
}
handleChange = (event, value) => {
this.setState({ value });
};
render() {
const {value, pathMap} = this.state;
return (
<BottomNavigation
value={value}
onChange={this.handleChange}
showLabels
className="nav primary"
>
<BottomNavigationAction label="Panoramas" icon={<LanguageIcon />} component={Link} to={pathMap[0]} />
<BottomNavigationAction label="Members" icon={<GroupIcon />} component={Link} to={pathMap[1]} />
<BottomNavigationAction label="Shop" icon={<ShoppingBasketIcon />} component={Link} to={pathMap[2]} />
<BottomNavigationAction label="About" icon={<HelpIcon />} component={Link} to={pathMap[3]} />
<BottomNavigationAction label="Subscribe" icon={<EmailIcon />} component={Link} to={pathMap[4]} />
</BottomNavigation>
);
}
}
export default withRouter(PrimaryNav);
And here's my version numbers for good measure:
"#material-ui/core": "^1.3.1",
"#material-ui/icons": "^1.1.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
Just found a really neat solution for this here:
Essentially you just create a pathname constant each render, using window.location.pathname and make sure that the value prop of each <BottomNavigationAction /> is set to the same as the route (including preceding forward slash) ...something like:
const pathname = window.location.pathname
const [value, setValue] = useState(pathname)
const onChange = (event, newValue) => {
setValue(newValue);
}
return (
<BottomNavigation className={classes.navbar} value={value} onChange={onChange}>
<BottomNavigationAction component={Link} to={'/'} value={'/'} label={'Home'} icon={<Home/>} />
<BottomNavigationAction component={Link} to={'/another-route'} value={'/another-route'} label={'Favourites'} icon={<Favorite/>} />
</BottomNavigation>
)
This means the initial state for value is always taken from the current URL.
I think you should avoid internal state management for this component. If you need to know and highlight the current selected route, you can just use NavigationLink from react-router-dom instead of Link. An "active" class will be added to the corresponding element. You just need to pay attention for the exact prop if you want the navigation element to be active only when an exact match is detected.
[Update] I wrote the wrong component name that is NavLink, not NavigationLink. My bad. Here is the link to the doc https://reactrouter.com/web/api/NavLink

Passing props in react-native-flux-router

So I'm still a bit new to React Native, but I've got an app working nearly how I want it to. I have App.js which uses the TabBarIOS component to display my tabbed navigation at the bottom of the screen. When you touch a tab, the state updates and the relevant content is loaded and displayed:
App.js
import React, { Component } from 'react';
import { TabBarIOS, Platform, Image } from 'react-native';
import IconII from 'react-native-vector-icons/Ionicons';
import IconMCI from 'react-native-vector-icons/MaterialCommunityIcons';
import Colors from './Colors';
import RouterItem1 from './routers/RouterItem1';
import RouterItem2 from './routers/RouterItem2';
import RouterHome from './routers/RouterHome';
import Settings from './components/Settings';
class FooterNav extends Component {
state = {
selectedTab: 'home',
};
handleClick = (routeData) => {
console.log('This has received data', routeData);
this.setState({ selectedTab: routeData });
console.log(this.state);
}
renderCurrentView() {
switch (this.state.selectedTab) {
case 'home':
return (
<RouterHome handleClick={this.handleClick} />
);
case 'item2':
return (
<RouterItem2 />
);
case 'item1':
return (
<RouterItem1 />
);
case 'settings':
return (
<Settings />
);
default:
return false;
}
}
render() {
return (
<TabBarIOS
unselectedTintColor={Colors.third} //Unselected labels
unselectedItemTintColor={Colors.third} //Unselected icons
tintColor={Colors.brandPrimary} //Selected
barTintColor={Colors.light} //Bar background
>
<IconII.TabBarItem
title="Home"
iconName="ios-home-outline"
selectedIconName="ios-home"
selected={this.state.selectedTab === 'home'}
receiveData={this.receiveData}
onPress={() => {
this.setState({
selectedTab: 'home',
});
}}
>
{this.renderCurrentView()}
</IconII.TabBarItem>
<TabBarIOS.Item
icon={require('./images/item2-icon-line#3x.png')}
selectedIcon={require('./images/item2-icon-selected#3x.png')}
title="item2"
selected={this.state.selectedTab === 'item2'}
onPress={() => {
this.setState({
selectedTab: 'item2',
});
}}
>
{this.renderCurrentView()}
</TabBarIOS.Item>
<IconMCI.TabBarItem
title="item1"
iconName="cookie"
selectedIconName="cookie"
selected={this.state.selectedTab === 'item1'}
onPress={() => {
this.setState({
selectedTab: 'item1',
});
}}
>
{this.renderCurrentView()}
</IconMCI.TabBarItem>
<IconII.TabBarItem
title="More"
iconName="ios-more-outline"
selectedIconName="ios-more"
selected={this.state.selectedTab === 'settings'}
onPress={() => {
this.setState({
selectedTab: 'settings',
});
}}
>
{this.renderCurrentView()}
</IconII.TabBarItem>
</TabBarIOS>
);
}
}
module.exports = FooterNav;
react-native-router-flux is a great plugin, once it pulls in a router the flow is exactly what I want it to be. The only problem I have is with the <RouterHome> module:
RouterHome.js
import React from 'react';
import { Scene, Router } from 'react-native-router-flux';
import styles from '../Styles';
import { content } from '../content.js';
import AnotherScene from '../components/pages/AnotherScene';
import Home from '../components/Home';
const RouterHomeComponent = () => {
return (
<Router
sceneStyle={styles.sceneStyle}
navigationBarStyle={styles.navBar}
titleStyle={styles.navBarTitle}
barButtonIconStyle={styles.barButtonIconStyle}
>
<Scene
key="Home"
component={Home}
title={content.heading}
hideNavBar
/>
<Scene
key="AnotherScene"
component={AnotherScene}
title='title'
hideNavBar={false}
/>
</Router>
);
};
export default RouterHomeComponent;
The default view that is loaded is the <Home> module:
Home.js
import React, { Component } from 'react';
import { Text, View, TouchableOpacity } from 'react-native';
import { Actions } from 'react-native-router-flux';
import styles from '../Styles';
import { content } from '../content.js';
class Home extends Component {
displayItem1 = () => {
this.props.handleClick('item1');
}
displayItem2 = () => {
this.props.handleClick('item2');
}
displayAnotherScene() {
Actions.AnotherScene();
}
render() {
return (
<View style={styles.viewWrapperHome}>
<Text style={styles.heading}>{content.greeting}</Text>
<TouchableOpacity onPress={this.displayItem1}>
<Text>First item</Text>
</TouchableOpacity>
<TouchableOpacity onPress={this.displayItem2}>
<Text>Second item</Text>
</TouchableOpacity>
<TouchableOpacity onPress={this.displayAnotherScene}>
<Text>Another scene</Text>
</TouchableOpacity>
</View>
);
}
}
export default Home;
So what I expect to happen is that if the user clicks on the first two buttons displayed on the screen (First item/Second item), the prop will be passed back to App.js, the state will change and the scene will be updated. It basically is an alternative way of navigating without using the footer menu.
I know that this would work without using the react-native-router-flux module as I had it running before I added it in. The problem is that I really need it to handle the other pages from the <Home> module (many more to add).
Can anyone suggest a way I can pass back the props through the router back to my App.js?
Okay, so I actually figured this out - it turned out to totally be my fault; the props weren't getting passed to RouterHome and so they got lost either side. The new RouterHome looks like this:
RouterHome.js
import React from 'react';
import { Scene, Router } from 'react-native-router-flux';
import styles from '../Styles';
import { content } from '../content.js';
import AnotherScene from '../components/pages/AnotherScene';
import Home from '../components/Home';
const RouterHomeComponent = (props) => { <---Didn't add props
return (
<Router
sceneStyle={styles.sceneStyle}
navigationBarStyle={styles.navBar}
titleStyle={styles.navBarTitle}
barButtonIconStyle={styles.barButtonIconStyle}
>
<Scene
key="Home"
component={Home}
title={content.heading}
hideNavBar
handleClick={props.handleClick} <---Didn't pass props
/>
<Scene
key="AnotherScene"
component={AnotherScene}
title='title'
hideNavBar={false}
/>
</Router>
);
};
export default RouterHomeComponent;
I've marked the two changes I made. Hopefully this will help someone! :)

Resources