GithubHelp home page GithubHelp logo

Comments (7)

kennydee avatar kennydee commented on April 19, 2024 21

Edit :
This seems a much better solution

I think using a React Component for "right" is better :)

right: could be a react component, which will handle himself his own props :)

For exemple my UserLogOutButtonComponent :

import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';

import {
  Button,
  Icon,
} from 'native-base';

import { userLogOut } from '../loginActions';

export const UserLogOutButtonComponent = (props) => {
  const {
    actions,
  } = props;
  return (
    <Button transparent onPress={actions.userLogOut}>
      <Icon name="ios-power" />
    </Button>
  );
};

UserLogOutButtonComponent.propTypes = {
  actions: PropTypes.shape({
    userLogOut: PropTypes.func,
  }).isRequired,
};

function mapDispatchToProps(dispatch) {
  return { actions: bindActionCreators({ userLogOut }, dispatch) };
}

export default connect(
  null,
  mapDispatchToProps,
)(UserLogOutButtonComponent);

And in my navigationOptions :

CurrentScreen.navigationOptions = {
  title: 'Welcome',
  header: {
    right: (<UserLogOutButton />),
  },
};

from react-navigation.

artembloom avatar artembloom commented on April 19, 2024 5

I found only this solution.
It works for my case, but I'm not sure this is correct for the others

componentWillUpdate(nextProps) {
  if (this.props !== nextProps) {
    if (nextProps.someProp) {
      const right = (
        <Button
          onPress={() => nextProps.navigation.navigate('SomeScreen')}
          title="SomeScreen"
        />
      )
      nextProps.navigation.setParams({ right })
    }
  }
}

CurrentScreen.navigationOptions = {
  title: 'CurrentScreen',
  header: ({ state }) => {
    if (state.params) {
      return { right: state.params.right }
    }
    return null
  }
}

from react-navigation.

temafedorov avatar temafedorov commented on April 19, 2024

+1

from react-navigation.

artembloom avatar artembloom commented on April 19, 2024

Answer #147

from react-navigation.

housseindjirdeh avatar housseindjirdeh commented on April 19, 2024

@chimon2000 that is correct. You can run the tests using webpagetest.org/easy for both Faster 3G and EM settings with the Lighthouse Audit checked. Once you're test completes, you can click the Lighthouse score to navigate to its associated report with which First Interactive is the time that we use for all of the implementations on the site.

from react-navigation.

b-asaf avatar b-asaf commented on April 19, 2024

#2638 My Question and Solution for: react component inside non-react component for header button

from react-navigation.

moahmed123 avatar moahmed123 commented on April 19, 2024

headerLeft: <Icon name='arrow-left' type='SimpleLineIcons' style={{color: '#16a085', fontSize: 18,paddingLift: 10}}/>

from react-navigation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.