A collection of tech notes, personal reflections, and evolving thoughts about whatever’s caught my curiosity.

notes

Browser default actions

18 February 2023

There are many default browser actions:

  1. mousedown – starts the selection (move the mouse to select).
  2. click on <input type="checkbox"> – checks/unchecks the input.
  3. submit – clicking an <input type="submit"> or hitting Enter inside a form field causes this event to happen, and the browser submits the form after it.
  4. keydown – pressing a key may lead to adding a character into a field, or other actions. contextmenu – the event happens on a right-click, the action is to show the browser context menu.
  5. …there are more…

All the default actions can be prevented if we want to handle the event exclusively by JavaScript.

To prevent a default action – use either event.preventDefault() or return false. The second method works only for handlers assigned with on<event>.

The passive: true option of addEventListener tells the browser that the action is not going to be prevented. That’s useful for some mobile events, like touchstart and touchmove, to tell the browser that it should not wait for all handlers to finish before scrolling.

If the default action was prevented, the value of event.defaultPrevented becomes true, otherwise it’s false.

References

javascript info

notes

Controlled and Uncontrolled Components

18 February 2023

A component with its own local state is often referred to as uncontrolled.

In contrast, a component is considered controlled when its key data and behavior are managed externally through props, rather than relying on its own local state. This approach allows the parent component to have full control over its behavior and data flow.

When designing a component, carefully consider which pieces of information should be controlled (managed via props) and which should remain uncontrolled (handled by the component’s state). However, keep in mind that you’re not locked into your initial decision—you can always refactor later as the needs of your application evolve.

References

React Doc, Freecodecamp

notes

Paddy fields

4 February 2023

From the beautiful paddy fields near to my home.

Chennithala, Kerala, India

Chennithala, Kerala, India

Chennithala, Kerala, India

Chennithala, Kerala, India

essay

Understanding JSX

4 February 2023
JSX is a XML-like syntax extension to ECMAScript (the acronym stands for JavaScript XML). Basically it just provides syntactic sugar...
essay

Codbix No.1

31 January 2023
Welcome to Issue #1 of The Codbix! This week: Learn In Public, Make free stuff, documentation, and Brag now.
notes

Back to home

28 January 2023

I’m back home, and I’m loving the early morning rides. Watching the sun rise over green fields, listening to the birds—everything is just so beautiful.

Haripad, Kerala, India

Haripad, Kerala, India

essay

Card shortcode for Hugo

25 January 2023
Shortcodes are simple snippets inside your content files calling built-in or custom templates.
essay

React components

20 January 2023
Conceptually, components are like JavaScript functions. They accept arbitrary inputs and return React elements describing what should appear on the screen.
essay

Keep Going Through the Valley of Disappointment.

15 January 2023
When working towards these goals, we often expect linear progress. We work hard and expect to see results, which seems fair, right?