use memo in react js code example

Example 1: useRef

/*
	A common use case is to access a child imperatively: 
*/

function TextInputWithFocusButton() {
  const inputEl = useRef(null);
  const onButtonClick = () => {
    // `current` points to the mounted text input element
    inputEl.current.focus();
  };
  return (
    <>
      <input ref={inputEl} type="text" />
      <button onClick={onButtonClick}>Focus the input</button>
    </>
  );
}

Example 2: import React, { memo } from 'react';

const MyComponent = React.memo(function MyComponent(props) {
  /* only rerenders if props change */
});

Example 3: how to add react.memo in export list

export const MemoMainPostTopic = React.memo(MainPostTopic);
 

//or

const MainPostTopic = memo(() => {
 ...
})
export { MainPostTopic };