Even with all its advantages, Local Storage comes with some limitations. One big disadvantage is that it can only store strings. However, we can come around this limitation using JSON.stringify and JSON.parse:
1
3
Using the Local Storage API is a great way to store small sets of data, such as user preferences in the browser, without having to rely on a database. It has:
✅ Easy to use API
✅ Low effort to implement
✅ Supports offline access
✅ Improved data privacy
1
61
Here are three different ways to use the Promise API in JavaScript:
1️⃣ Use Promise.all to handle multiple promises at once
1
56
4️⃣ Provider pattern: If you're dealing with more than one provider in your React application, you can collect them into one component at the root of your tree for improved readability
1
44
3️⃣ Render props: Need to uncouple the rendering logic from your component? You can use a render prop which can define how to render the component from the outside.
1
13
2️⃣ Higher-order components: a pattern used for reusing component logic. Take the following example which conditionally wraps elements. It can:
✅ Simplify conditions
✅ Prevent DOM pollution with empty elements
1
4
Here are four patterns you can use in React to improve your codebase:
1️⃣ Child-to-parent communication: Most commonly, you want to lift your state when you want to pass data from child-to-parent components. However, you can also use callback functions:
If you worry less about formatting, you can also use JSON.stringify wrapped in a pre tag for proper indentation:
1
36
💡 Want to display a JavaScript object in a readable way in your React app? You can use a combination of Object.keys with a map to create a loop and display the data in a tabular format:
💡 Want to prevent elements from receiving click events? Here are three solutions you can use:
1️⃣ Set the `disabled` attribute in HTML
2️⃣ Set `pointer-events` to `none` in CSS
3️⃣ Call `event.preventDefault` in JavaScript
💡 A quick way to improve the installation UI of your PWA is to define the screenshots property in your manifest file. This can add a carousel of images about your app during installation.
(📚 Read more about the format: web.dev/articles/add-manifes…)
43
💡 Want to screenshot part of your website? You can select a DOM element in Chrome DevTools on the Elements panel, then search for "screenshot" in the command panel (ctrl + shift + p) and choose "Capture node screenshot". You can also capture the entire site or the visible area.
62














