React components
Keep Going Through the Valley of Disappointment.
Module in JS
A module is just a file. One script is one module. As simple as that.
- To make
import/exportwork, browsers need<script type="module">. - Modules have several differences:
- Deferred by default.
- Async works on inline scripts.
- To load external scripts from another origin (domain/protocol/port), CORS headers are needed.
- Duplicate external scripts are ignored.
- Modules have their own, local top-level scope and interchange functionality via import/export.
- Modules always use strict.
- Module code is executed only once. Exports are created once and shared between importers.
When we use modules, each module implements the functionality and exports it. Then we use import to directly import it where it’s needed. The browser loads and evaluates the scripts automatically.
In production, people often use bundlers such as Webpack to bundle modules together for performance and other reasons.
References
Why I am writing in the time of Reels?
Oracle Timestamp
The TIMESTAMP datatype is an extension on the DATE datatype. In addition to the datetime elements of the DATE datatype, the TIMESTAMP datatype holds fractions of a second to a precision between zero and nine decimal places, the default being six. There are also two variants called TIMESTAMP WITH TIME ZONE and TIMESTAMP WITH LOCAL TIME ZONE. As their names imply, these timestamps also store time zone offset information.
create table table_name (
column_name number,
column_name2 timestamp default systimestamp);
References
Material UI and Emotion
Material UI uses Emotion as its default styling engine.
Run the following commands to add Material UI to your project:
npm install @mui/material @emotion/react @emotion/styled
Emotion Emotion is a library designed for writing css styles with JavaScript. It provides powerful and predictable style composition in addition to a great developer experience with features such as source maps, labels, and testing utilities. Both string and object styles are supported.
There are two primary methods of using Emotion. The first is framework agnostic and the second is for use with React.
Styled Components
styled is a way to create React components that have styles attached to them. It’s available from @emotion/styled. styled was heavily inspired by styled-components and glamorous.
import styled from '@emotion/styled'
const Button = styled.button`
padding: 32px;
background-color: hotpink;
font-size: 24px;
border-radius: 4px;
color: black;
font-weight: bold;
&:hover {
color: white;
}
`
render(<Button>This my button component.</Button>)
References
Differenet types of errors in JS
Syntax error
The error occurs when you use a predefined syntax incorrectly.
Reference Error
In a case where a variable reference can’t be found or hasn’t been declared, then a Reference error occurs.
Type Error
An error occurs when a value is used outside the scope of its data type.
RangeError
There is an error when a range of expected values is required
URI Error
When the wrong character(s) are used in a URI function, the error is called.
InternalError
This error occurs internally in the JS engine, especially when it has too much data to handle and the stack grows way over its critical limit.
Evaluation Error
Current JavaScript engines and EcmaScript specifications do not throw this error. However, it is still available for backward compatibility. The error is called when the eval() backward function is used.