├── ExampleNavigation ├── .watchmanconfig ├── .gitattributes ├── android │ ├── settings.gradle │ ├── app │ │ ├── src │ │ │ └── main │ │ │ │ ├── res │ │ │ │ ├── values │ │ │ │ │ ├── strings.xml │ │ │ │ │ └── styles.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ └── mipmap-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── examplenavigation │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── MainApplication.java │ │ │ │ └── AndroidManifest.xml │ │ ├── BUCK │ │ ├── proguard-rules.pro │ │ └── build.gradle │ ├── keystores │ │ ├── debug.keystore.properties │ │ └── BUCK │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── build.gradle │ ├── gradle.properties │ ├── gradlew.bat │ └── gradlew ├── app.json ├── .babelrc ├── .buckconfig ├── index.ios.js ├── index.android.js ├── README.md ├── app │ ├── styles.js │ ├── screen3.js │ ├── app.js │ ├── screen4.js │ ├── screen2.js │ └── screen1.js ├── ios │ ├── ExampleNavigation │ │ ├── AppDelegate.h │ │ ├── main.m │ │ ├── Images.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── AppDelegate.m │ │ ├── Info.plist │ │ └── Base.lproj │ │ │ └── LaunchScreen.xib │ ├── ExampleNavigationTests │ │ ├── Info.plist │ │ └── ExampleNavigationTests.m │ ├── ExampleNavigation-tvOSTests │ │ └── Info.plist │ ├── ExampleNavigation-tvOS │ │ └── Info.plist │ └── ExampleNavigation.xcodeproj │ │ ├── xcshareddata │ │ └── xcschemes │ │ │ ├── ExampleNavigation.xcscheme │ │ │ └── ExampleNavigation-tvOS.xcscheme │ │ └── project.pbxproj ├── package.json ├── .gitignore └── .flowconfig ├── .npmignore ├── .gitignore ├── issue_template.md ├── package.json ├── LICENSE ├── index.js └── README.md /ExampleNavigation/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /ExampleNavigation/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | ExampleNavigation/ 2 | issue_template.md 3 | .git* 4 | -------------------------------------------------------------------------------- /ExampleNavigation/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'ExampleNavigation' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /ExampleNavigation/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ExampleNavigation", 3 | "displayName": "ExampleNavigation" 4 | } -------------------------------------------------------------------------------- /ExampleNavigation/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"], 3 | "plugins": ["transform-decorators-legacy"] 4 | } 5 | -------------------------------------------------------------------------------- /ExampleNavigation/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ExampleNavigation 3 | 4 | -------------------------------------------------------------------------------- /ExampleNavigation/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /ExampleNavigation/android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /ExampleNavigation/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-mach/react-navigation-is-focused-hoc/HEAD/ExampleNavigation/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /ExampleNavigation/index.ios.js: -------------------------------------------------------------------------------- 1 | import { 2 | AppRegistry, 3 | } from 'react-native' 4 | 5 | import App from './app/app' 6 | 7 | AppRegistry.registerComponent('ExampleNavigation', () => App) 8 | -------------------------------------------------------------------------------- /ExampleNavigation/index.android.js: -------------------------------------------------------------------------------- 1 | import { 2 | AppRegistry, 3 | } from 'react-native' 4 | 5 | import App from './app/app' 6 | 7 | AppRegistry.registerComponent('ExampleNavigation', () => App) 8 | -------------------------------------------------------------------------------- /ExampleNavigation/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-mach/react-navigation-is-focused-hoc/HEAD/ExampleNavigation/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /ExampleNavigation/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-mach/react-navigation-is-focused-hoc/HEAD/ExampleNavigation/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /ExampleNavigation/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-mach/react-navigation-is-focused-hoc/HEAD/ExampleNavigation/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ExampleNavigation/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-mach/react-navigation-is-focused-hoc/HEAD/ExampleNavigation/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ExampleNavigation/android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = "debug", 3 | properties = "debug.keystore.properties", 4 | store = "debug.keystore", 5 | visibility = [ 6 | "PUBLIC", 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /ExampleNavigation/README.md: -------------------------------------------------------------------------------- 1 | #### `Run example` 2 | 3 | From project root run in terminal: 4 | - `cd ExampleNavigation/` 5 | - `yarn install` 6 | 7 | For Android: 8 | - `react-native run-android` 9 | 10 | For iOS: 11 | - `react-native run-ios` 12 | -------------------------------------------------------------------------------- /ExampleNavigation/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ExampleNavigation/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # VSCode 2 | .vscode/ 3 | jsconfig.json 4 | 5 | # IntelliJ/Webstorm 6 | .idea 7 | 8 | # NodeJS 9 | npm-debug.log 10 | node_modules 11 | lib-rn 12 | lib 13 | yarn-error.log 14 | 15 | # OS X 16 | .DS_Store 17 | 18 | # Exponent 19 | .exponent 20 | 21 | # Jest 22 | coverage 23 | -------------------------------------------------------------------------------- /issue_template.md: -------------------------------------------------------------------------------- 1 | ### Steps to reproduce 2 | 1. 3 | 2. 4 | 3. 5 | 6 | ### Expected behaviour 7 | Tell us what should happen 8 | 9 | ### Actual behaviour 10 | Tell us what happens instead 11 | 12 | ### Environment 13 | - **React Navigation version**: 14 | - **Node.js version**: 15 | - **React Native version**: 16 | - **React Native platform + platform version**: iOS 9.0, Android 5.0, etc 17 | 18 | ### react-navigation-is-focused-hoc 19 | **Version**: npm version or "master" 20 | -------------------------------------------------------------------------------- /ExampleNavigation/android/app/src/main/java/com/examplenavigation/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.examplenavigation; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "ExampleNavigation"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ExampleNavigation/app/styles.js: -------------------------------------------------------------------------------- 1 | import { 2 | StyleSheet, 3 | } from 'react-native'; 4 | 5 | export default StyleSheet.create({ 6 | container: { 7 | flex: 1, 8 | justifyContent: 'center', 9 | alignItems: 'center', 10 | backgroundColor: '#F5FCFF', 11 | }, 12 | welcome: { 13 | fontSize: 20, 14 | textAlign: 'center', 15 | margin: 10, 16 | }, 17 | instructions: { 18 | textAlign: 'center', 19 | color: '#333333', 20 | marginBottom: 5, 21 | }, 22 | goButton: { 23 | margin: 20, 24 | } 25 | }) 26 | -------------------------------------------------------------------------------- /ExampleNavigation/ios/ExampleNavigation/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ExampleNavigation/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ExampleNavigation", 3 | "version": "0.0.2", 4 | "private": true, 5 | "author": "Peter Machowski 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ExampleNavigation/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenLocal() 18 | jcenter() 19 | maven { 20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 21 | url "$rootDir/../node_modules/react-native/android" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ExampleNavigation/ios/ExampleNavigation/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ExampleNavigation/ios/ExampleNavigationTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ExampleNavigation/ios/ExampleNavigation-tvOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-navigation-is-focused-hoc", 3 | "version": "1.1.1", 4 | "description": "Ready to use solution using HOC to expose props.isFocused for react-navigation. No Redux needed.", 5 | "main": "index.js", 6 | "scripts": { 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/pmachowski/react-navigation-is-focused-hoc.git" 11 | }, 12 | "keywords": [ 13 | "react-navigation", 14 | "hoc", 15 | "isFocused", 16 | "react-native", 17 | "navigation" 18 | ], 19 | "author": "Peter Machowski getPackages() { 24 | return Arrays.asList( 25 | new MainReactPackage() 26 | ); 27 | } 28 | }; 29 | 30 | @Override 31 | public ReactNativeHost getReactNativeHost() { 32 | return mReactNativeHost; 33 | } 34 | 35 | @Override 36 | public void onCreate() { 37 | super.onCreate(); 38 | SoLoader.init(this, /* native exopackage */ false); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ExampleNavigation/app/screen3.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react' 2 | import { 3 | Text, 4 | View, 5 | Button, 6 | } from 'react-native'; 7 | 8 | import { withNavigationFocus } from 'react-navigation-is-focused-hoc' 9 | 10 | import styles from './styles' 11 | 12 | class Screen3 extends Component { 13 | static navigationOptions = { 14 | title: 'Screen 3', 15 | } 16 | 17 | componentDidMount() { 18 | console.log(`Screen 3 did Mount`) 19 | } 20 | 21 | componentWillUnmount() { 22 | console.log(`Screen 3 did Unmount`) 23 | } 24 | 25 | render() { 26 | const { navigate } = this.props.navigation 27 | 28 | console.log(`render() Screen 3 props.isFocused: ${this.props.isFocused}`) 29 | 30 | return ( 31 | 32 | 33 | Welcome to Screen 3! 34 | 35 | 36 | {`To see props.isFocused in action\nopen dev menu and 'Debug JS Remotely'`} 37 | 38 |