Mehedi Hassan Piash [Sr. Software Engineer]

September 29, 2019

Call back function in react-naitve

September 29, 2019 Posted by Piash No comments

How to send data current page to previous page using callBack in react - native.

import React, {  Component} from 'react';
import { Text, TouchableOpacity} from 'react-native';
import {Actions} from 'react-native-router-flux';

export default class FirstScreen extends Component {
    constructor(props) {
        super(props);
    }
    onCallBack(data) {
        console.log(data);
    }
    render() {
        return (
<TouchableOpacity
        onPress = {  () => {
                    Actions.SecondScreen({
                        onCallBack: this.onCallBack.bind(this)
                    });
                }
            } >
            <Text > SecondScreen < /Text>         
 </TouchableOpacity >
        );
    }
}
###############-- -- -- -- -- -- -- -- -- -- -- - ########################
import React, { Component} from 'react';
import {  Text,TouchableOpacity} from 'react-native';
import { Actions} from 'react-native-router-flux';

export default class SecondScreen extends Component {
    constructor(props) {
        super(props);
    }
    render() {
        return (
< TouchableOpacity
         onPress = { () => {
                    this.props.onCallBack('data of previous screen')
                    Actions.pop()
                }
            } >
            <Text > BackToScreen < /Text>       
   </TouchableOpacity > );

    }
}

September 25, 2019

Git Bibel [Git command]

September 25, 2019 Posted by Piash No comments

  • Clone repository : git clone "repository_name"
  • Commit changes : git commit -m "[commit message]"
  • Show last five commit : git log --oneline -5
  • Merging multiple commit to single commit: git merge --squash [branch_name]
  • Git fetch : git fetch origin
  • CheckOut with a new local branch: git checkout -b name origin/develop
  • Push only changes: git push origin HEAD:refs/for/develop
  • Modify existing pushed commit by Id: git push origin HEAD:refs/changes/53172
  • Cherry-pick [Particular commit]: git cherry-pick c41a50e8[commit_id]
  • Save uncommitted change: git stash
  • Save uncommitted change by Id: git stash save 'abc_stash'
  • Reset current changes till last commit: git reset --hard'