Forwarding Ref in React Hooks Env

Forwarding Ref in React Hooks Env

In this posting, we’re going to study about ‘useRef’ hooks and ‘forwardRef’ feature while making side menu in React App.

In this posting, we’re going to study about ‘useRef’ hooks and ‘forwardRef’ features while making the side menu in React App.

1. setup app and make SideMenu component

At first, setup the react hooks development environment by ‘create-react-app’.

$ npx create-react-app forward-ref-tutorial --template typescript

After the app is created, we can see the App component written by typescript.

Image for post

Now, let’s make a component named ‘SideMenu’.

// SideMenu.tsx

import React from 'react';
import './SideMenu.css';
function SideMenu() {
  return (
    <div className="side-menu">
      Hi, I'm SideMenu
    </div>
  );
}
export default SideMenu;

And then, I set some CSS code to make the component visible well.

// SideMenu.css

import React from 'react';
import './SideMenu.css';
function SideMenu() {
  return (
    <div className="side-menu">
      Hi, I'm SideMenu
    </div>
  );
}
export default SideMenu;

react-hook react

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How native is React Native? | React Native vs Native App Development

Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.

What are hooks in React JS? - INFO AT ONE

In this article, you will learn what are hooks in React JS? and when to use react hooks? Also, we will see the react hooks example.

Validating React Forms With React-Hook-Form

In this article we will learn how to Validating React Forms With React-Hook-Form . Validating inputs is very often required. For example, when you want to make sure two passwords inputs are the same, an email input should in fact be an email or that the input is not too long

Hooks, Hooks, Hooks!

Hooks are functions, provided by React (and completely opt-in, not required), that allows you to “hook into” React features from functional components. So you can continue to use functional components, which are inherently simpler and less bloated, and access state.

The Ugly Side of React Hooks

In this post, I will share my own point of view about React Hooks, and as the title of this post implies, I am not a big fan.