Posts

Showing posts from November, 2020

React's useImperativeHandle with practical example | by ByteCode Pandit

Image
Hi, all techies today we are going to discuss the react's important hook useImperativeHandle. What it solved for me When I was working on a react-native project, there was a situation when I have to toggle the modal view. So for that, I just took another boolean state in the parent component and changed it. import React , { useState } from 'react' ; import { Pressable , Text , View } from 'react-native' ; export const ParentComponent = ( props : any ) => { const [ showModal , setShowModal ] = useState < boolean >( false ); const toggleModal = ( value : boolean ) => { setShowModal ( value ); } return < View > < Pressable onPress = { () => toggleModal ( true ) } >< Text > Show Modal </ Text ></ Pressable > { showModal && < ModalComponent /> } </ View > } But because as we know whenever we change the state of the component it gets rerender wh...

How to manage multiple git accounts (Ubuntu/ Mac) | by ByteCode Pandit

Image
Hi, all teach worries, usually, we fall in a situation where we have to use both our personal as well as office GitHub account. So today I am gonna show you how can we manage multiple GitHub account on a machine. For now, I will set up two accounts. Please follow the below steps. Step 1 : Have to create the ssh key for your accounts $ cd ~/.ssh $ ssh-keygen -t rsa -b 4096 -C "peronsal_email_id"  # save as id_rsa_personal $ ssh-keygen -t rsa -b 4096 -C "office_email_id"  # save as id_rsa_office Step 2 : Have to add id_rsa_personal.pub and  id_rsa_office .pub to their respective Github account. Step 3 : Create a config file in the .ssh folder and add the below configs $ touch config  # Personal account - default config  Host github.com-personal    HostName github.com    User git    IdentityFile ~/.ssh/ id_rsa_personal  # Work account   Host github.com-office    HostName github.com    User git   ...