Posts

Showing posts with the label Reusable code

How to create custom hook in react?

Image
In React, a custom hook is a JavaScript function that starts with the word “use” and that can call other hooks. Custom hooks allow you to extract component logic into reusable functions. To create a custom hook, you can define a function that starts with the word “use” and that includes any logic that you want to reuse. You can then call this function within your components to access the logic it contains. Here is an example of a simple custom hook that manages the state of a toggle button: This custom hook uses the built-in  useState  hook to manage a piece of state that represents whether the toggle button is on or off. It also defines a function called  toggle  that can be used to toggle the state. The hook returns an array that contains the current state and the toggle function. Then you can use this custom hook in your component: In this example, the  MyToggleButton  component calls the  useToggle  custom hook and destructures the returned ar...

What is fabric architecture in react?

Image
What is fabric architecture in react? Fabric is the new rendering system for React Native. It is a conceptual improvement on the old render system. Unlocking new capabilities for React Native, enhancing interoperability with host platforms, and unifying more render logic in C++ are the fundamental principles. The Facebook app's development began in 2018, and the new renderer will support React Native in 2021. Better user experiences that were not possible with the legacy architecture were made possible by the render architecture. Here are some examples: React Fabric is a set of libraries and components for using the Microsoft Fabric design system to build web applications with React. Fabric is a set of design principles and user interface (UI) components that developers can use to create applications that are consistent, visually appealing, and easy to use. Button, form, list, and other pre-built UI components, all of which adhere to the Fabric design guidelines, are available from...