author avatar

keshav.chakravarthy

Sun May 14 2023

author avatar

ashwanikumarjha

Sun May 07 2023

TypeScript Pick utility allows us to create a new type by picking a subset of properties from an existing type. Instead of duplicating field declarations we can use Pick utility to extract new types.

type AdminUser = {
  id: number;
  name: string;
  email: string;
  phone: string;
  password: string;
  age: number;
  isAdmin:  boolean;
  ...
}
type BasicUser = Pick<AdminUser, 'id' | 'name' | 'email'>;
author avatar

rishav.raj

Fri May 05 2023

today i learned how to use storybook in next js with typescript and i also build some story of the components and today i learn how next js work and i also fetch api data in next js with the typescript and i also write the test cases in next js by using the react testing library and jest and i learned how to write testcases in react js with the help of typescript

author avatar

ayushsrivastava

Thu May 04 2023

A modal is a popup that when appears on the screen we cannot interact with any other element on the webpage apart from the modal. On other hand a dialog is a popup that when appears on the screen we can still interact with other element on the webpage

<dialog>
<!-- Dialog Content -->
</dialog>

By default a dialog element will be hidden unless you add the open attribute to your dialog

<dialog open>
  <span>You can see me</span>
</dialog>

It is not advised to use the open attribute directly, though, as that only allows you to open a non-modal dialog. Instead, you should use the show() and showModal() JavaScript methods.

const dialog = document.querySelector("dialog")
dialog.show() // Opens a non-modal dialog
dialog.showModal() // Opens a modal

To close a dialog element you just need to use the close() method. Alternatively, if your dialog element is a modal you can use the Esc key to close it.

const dialog = document.querySelector("dialog")
dialog.close() // Closes the dialog
author avatar

rishav.raj

Thu May 04 2023

today i learned

  1. All the basics of typescript and i also implement for fetching the api
  2. i learned tailwind css and also implement styles in the component using tailwind css. so basically today i learn how typescript work, how to implement typescript, how it is useful in development and how to use and implement tailwind css.
author avatar

syedsibtain

Thu May 04 2023

When we have conflicts between main and production, we cannot open PR directly. We do the following:

  1. git fetch and then go to production -> git checkout production
  2. Create a new branch from production -> git checkout -b <branchname>
  3. Pull latest changes from main -> git pull origin main or git merge main
  4. Resolve conflicts
  5. Push the changes and create a pull request with base branch as production
  6. And chill :slightly_smiling_face:
author avatar

rishav.raj

Wed May 03 2023

Today I learned

1 Fetch data from Api. 2 How to use axios for Fetching Api. 3 How to use storybook. 4 Learned jest for writing test cases.

author avatar

ayushsrivastava

Wed May 03 2023

git reset --hard origin/master
says: throw away all my staged and unstaged changes, forget everything on my current local branch and make it exactly the same as origin/master.

You probably wanted to ask this before you ran the command. The destructive nature is hinted at by using the same words as in "hard reset".
author avatar

syedsibtain

Thu Apr 27 2023

So if we want to mock the useRouter hook in NextJs, we can use vi for it. The "vi" library's function vi.mock allows us to simulate the behaviour of the useRouter hook. The mock function returns an object that mimics the Router object's properties and methods.

vi.mock("next/router", () => ({
    useRouter: () => ({
      replace: vi.fn(),
    }),
  }));

replace: a mock function that simulates the behavior of the replace method of the Router object. If we do not use it, the test might fail and we get the following error. Error: NextRouter was not mounted.

Showing 30 to 32 of 66 results