Categories
Javascript

Working example of React Ref api

What is React Ref? Its another way of communicating with react components apart from “state” and “props” (Ref = creating reference of element). We need it to access the element node, to perform special type of events like “focusing a input element”, text selection. How React Ref works? After React 16.3, it came in the […]

Categories
Apex Salesforce

Apex Superbadge (part-1)

Scenario:- Automate record creation Install the unmanaged package for the schema and stubs for Apex classes and triggers. Rename cases and products to match the HowWeRoll schema, and assign all profiles to the custom HowWeRoll page layouts for those objects. Use the included package content to automatically create a Routine Maintenance request every time a […]

Categories
Salesforce

Creating a salesforce lightning web component in visual studio code

import { LightningElement, track } from ‘lwc’; export default class HelloLWC extends LightningElement { //default values @track typedValue = ”; salutationOptions = [ {‘label’: ‘None’, ‘value’: ‘None’}, {‘label’: ‘Mr.’, ‘value’: ‘Mr.’}, {‘label’: ‘Ms.’, ‘value’: ‘Ms.’}, {‘label’: ‘Mrs.’, ‘value’: ‘Mrs.’}, {‘label’: ‘Dr.’, ‘value’: ‘Dr.’}, {‘label’: ‘Prof.’, ‘value’: ‘Prof.’}, ]; //method on click of button handleClick(){ const […]

Categories
Salesforce

How to use visual studio code for Salesforce?

Lets learn how to create Salesforce project in visual studio code editor Install sfdx-cli on your pc by typing command in terminal > npm install -g sfdx-cli Verify installation is complete > sfdx -version Install the Salesforce Extension Pack, inside vscode > extensions > Salesforce Extension Pack Create sfdx project in vscode press cmd+shift+p inside […]

Categories
Javascript

Fix lint errors in Angular cli

The mind, once stretched by a new idea, never regains its original dimensions. Problem:- In Angular cli after executing the command ng lint shows a lot of lint errors based on the configuration `tslint.json`, how to fix lint errors ? Solution:- Run the below command tslint –fix src/**/*.ts -t verbose Note:– It will fix most of the […]

Categories
Javascript

Removing git tags before publishing

How we can remove npm/git tags before publishing:- git tag -d tagName git push origin :refs/tags/tagName Example:- ➜ git:(master) ✗ npm version patch v19.3.2 ➜ git:(master) git tag -d v19.3.2 Deleted tag ‘v19.3.2’ (was 7d16814)

Categories
Javascript

Using JS to add div elements dynamically

Scenario:- Legacy code thrown at you with new UX design, and you cannot touch the original code. So doing latest UI changes is headache. Solution:- Play with the structure of the html and add latest flexbox or grid CSS to make your life hell easier. How i did re-structuring was appending new parent div, which […]

Categories
Javascript React

How to debug jest test cases(React)?

Adding test cases to your code always helps in the long run, today we’re going to talk about how to debug test cases. Do something today that your future self will thank you for Using our all-time favorite Console.log it(‘should call touch & asyncValidate methods’, () => { const component = shallow( <TrialRegistrationForm handleSubmit={mockHandleSubmit} pristine […]

Categories
Javascript

Console.log trick for debugging

Why need see our debug messages bigger and brighter, simply use the below trick. console.log(‘%c This is my log for debugging’, ‘font-size: 40px; color: green;’); “Striving for excellence motivates you; striving for perfection is demoralizing.”  

Categories
Javascript

How to update node to a given version

Scenario:- Update node to the given version ? Solution:-  Using nvm:-Node Version Manager Install nvm  curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash Reopen the terminal Check nvm is installed by typing nvm > enter > it will show nvm commands nvm install Node_Version_i_Want $ nvm install 8.9.4 Note:- After installing the latest node incase your build fails […]