Description A Promise is a proxy for a value not necessarily known when the promise is created. The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value. Instead of callback functions, it allows you to associate handlers with an asynchronous action’s eventual success value or failure reason. This lets asynchronous methods return […]
Category: JavaScript
[Package] react-beautiful-dnd
[Error] Cannot stop drag when no active drag Ref https://github.com/atlassian/react-beautiful-dnd/issues/1778#issuecomment-836542941
Number
Handle with Price: 2 decimal places Ref https://stackoverflow.com/questions/3163070/javascript-displaying-a-float-to-2-decimal-places
[Package] styled-components
Motivation Automatic critical CSS: styled-components keeps track of which components are rendered on a page and injects their styles and nothing else, fully automatically. Combined with code splitting, this means your users load the least amount of code necessary. No class name bugs: styled-components generates unique class names for your styles. Simple dynamic styling: adapting […]
[Package] date-fns
Comparison with MomentJs date-fns vs moment Problems with Moment.js: It is highly based on OOP APIs, which makes it fail to work with tree-shaking, thus leading to a huge bundle size and performance issues. It is mutable and it causes bugs Complex OOP API (which doubles mutability problem) Advantages of date-fns Function per file Date-fns library consists […]
https://stackoverflow.com/questions/47012169/a-component-is-changing-an-uncontrolled-input-of-type-text-to-be-controlled-erro Cause: An input field will become uncontrolled when the initial value is undefined Solution:
Object
Use variable for key in Object https://stackoverflow.com/questions/11508463/javascript-set-object-key-by-variable Comparison https://stackoverflow.com/questions/1068834/object-comparison-in-javascript
Date
Copy / clone a Date object getTime() method, which returns the number of milliseconds since 1 January 1970 00:00:00 UTC + sign is unaray operator here. It means new Date(Number(orig)) https://stackoverflow.com/questions/1090815/how-to-clone-a-date-object Update a state object with Date type in React Return a different object in setMyDate so that React can tell it has been modified https://stackoverflow.com/questions/72388233/adding-a-day-to-react-state-date-object-created-using-usestate
Get the Monday of the Current week
https://bobbyhadz.com/blog/javascript-get-monday-of-current-week The getDate method returns an integer between 1 and 31 that represents the day of the month for the given date The getDay method returns an integer between 0 (Sunday) and 6 (Saturday) that represents the day of the week for the date The return value of setDate() is the number of milliseconds between 1 January 1970 00:00:00 […]
Full Stack JavaScript Development What is Node.js? JavaScript runtime built on Chrome V8 JavaScript Engine Uses an event-driven, non-blocking I/O model – lightweight & efficient What is package.json? Usage documentation for what packages including their versions, your project depends on makes build reproducible Commands npm init – in project folder, follow prompt Online Git repos […]