-- online Search!

Avoiding Unnecessary Renders in React

by kirupa   |   filed under Learning React

TL;DR

A render is React calling your component function, and by default every child renders whenever its parent does, even if nothing it shows changed. You can spot this with console.log and skip those wasted renders using memo, plus useCallback and useMemo, or let the React Compiler handle much of it automatically.

  • A render isn't a DOM update: React compares new JSX to the old and only touches the DOM where things differ, but calling components and comparing still costs work.
  • A component renders on first appearance, when its state changes, when a context it reads changes, or when its parent renders.
  • In development, StrictMode deliberately renders each component twice to catch impure code, so comment it out temporarily to see one message per render.
  • memo remembers a component's last output and props, and when every prop is the same it skips rendering and reuses the old result.

One of the biggest feathers in React's cap is that it is fast. That doesn't mean you get all of that speed for free, though. React does a lot of heavy lifting for you, but it can't know which parts of your app really need to update and which parts are just along for the ride. A component that does nothing more than redraw the exact same thing it drew a moment ago is wasted work, and enough of that wasted work can make an app feel sluggish.

In this tutorial, we'll look at what a render actually is, why components render more often than you might expect, and what you can do to skip the renders you don't need. We'll look at the manual tools React gives us (memo, useCallback, and useMemo), and then we'll see how the React Compiler can do much of this work for us automatically.

Onwards!

What a Render Is

When we talk about a component rendering, all we mean is that React calls your component function and asks, "What should this look like right now?" Your function runs from top to bottom, and it returns some JSX. React takes that JSX, along with the JSX from every other component being rendered, and uses it to figure out what the page should look like.

Here is the part that surprises people. A render is not the same thing as the DOM being updated. After React gets the JSX back from your components, it compares it with the JSX from the previous render and only touches the DOM for the things that are different. If a component renders and returns exactly what it returned last time, the DOM is left alone. That's good news, because touching the DOM is the expensive part.

It isn't entirely free news, though. Calling your component function, building up the JSX, and comparing it with the old JSX is all work. For a single tiny component, that work is meaningless. For hundreds of components that do some real calculations inside them, it adds up.

What Causes a Component to Render

There are only a few reasons a component will render:

  1. It renders for the very first time when it appears on the page
  2. Its own state changes (such as when you call a state setter from useState with a new value)
  3. A context it is reading changes (we'll look at that in Sharing Data with Context)
  4. Its parent component renders

That last one is the important one for us. Notice what is not on that list: a component's props changing. Props change because a parent rendered and passed down new values, so the parent's render is the real cause. By default, when a component renders, every component it returns renders too, and every component those components return, all the way down the tree. React doesn't stop to ask whether a child's props are the same as last time.

For many components, that is the right thing to do. If the state in a parent changed, there is a good chance the children need to show something different. But very often, a child doesn't care about the state that just changed. It is being forced to render anyway. Let's see this with an example.

Getting an Example Going

We are going to use the sliding menu we created in the previous tutorial. If you have that project handy, open it up in your code editor. If you don't, create a new project using Vite by following the steps in Setting Up Your React Development Environment, and then re-create the sliding menu from the previous tutorial.

Our app has a MenuContainer component that holds the state for whether the menu is visible. Inside it, we have a MenuButton, a Menu, and a little block of content below them with a list of items. Both MenuButton and Menu use the visible value we pass in, so it makes total sense for them to render whenever the menu opens or closes. That list of items, on the other hand, couldn't care less about whether the menu is open.

To make this easier to work with, let's turn that list into its own component. Create a new file named ItemList.jsx in your src folder and add the following into it:

function ItemList() {
  console.log("Rendering: ItemList");

  return (
    <div>
      <p>Can you spot the item that doesn't belong?</p>
      <ul>
        <li>Lorem</li>
        <li>Ipsum</li>
        <li>Dolor</li>
        <li>Sit</li>
        <li>Bumblebees</li>
        <li>Aenean</li>
        <li>Consectetur</li>
      </ul>
    </div>
  );
}

export default ItemList;

This is the same list we had before, just living in its own component. The highlighted line is a console.log call that will print a message every time this component renders. That is going to be how we spy on React. Next, let's use this component in MenuContainer. Make the following highlighted changes to MenuContainer.jsx:

import { useState, useEffect } from "react";
import MenuButton from "./MenuButton.jsx";
import Menu from "./Menu.jsx";
import ItemList from "./ItemList.jsx";

function MenuContainer() {
  console.log("Rendering: MenuContainer");

  const [visible, setVisible] = useState(false);

  function toggleMenu() {
    setVisible((current) => !current);
  }

  useEffect(() => {
    if (!visible) {
      return;
    }

    function handleKeyDown(e) {
      if (e.key === "Escape") {
        setVisible(false);
      }
    }

    document.addEventListener("keydown", handleKeyDown);
    return () => document.removeEventListener("keydown", handleKeyDown);
  }, [visible]);

  return (
    <div>
      <MenuButton toggleMenu={toggleMenu} visible={visible} />
      <Menu toggleMenu={toggleMenu} visible={visible} />
      <ItemList />
    </div>
  );
}

export default MenuContainer;

We import ItemList, add a console.log of our own, and replace the old block of content with our new component. To finish the setup, open MenuButton.jsx and Menu.jsx and add a similar line as the first line inside each function:

function MenuButton({ toggleMenu, visible }) {
  console.log("Rendering: MenuButton");

  // the rest of the function stays the same
}

In Menu.jsx, the message should say Rendering: Menu instead.

Dealing with StrictMode

Before we preview our app, there is something to know about main.jsx. Our app is wrapped in a StrictMode component. When your app is running in development, StrictMode deliberately renders each component twice to help you catch code that isn't behaving. React expects rendering to be a pure calculation. The same props, state, and context should always give back the same JSX, and rendering a component shouldn't change anything outside of it. Calling your component twice is a quick way to reveal any code that breaks that rule. It only happens while you are developing, and your users never see it.

That's a great safety net, but it makes our experiment confusing, because every message we print will show up twice. For the next few sections, temporarily comment out StrictMode in main.jsx so that you see one message per render:

createRoot(document.getElementById("root")).render(
  // <StrictMode>
    <MenuContainer />
  // </StrictMode>
);

Your editor or linter may complain that StrictMode is imported but never used. That's fine for now, and it goes away when you put it back. Which you will do when we are done!

Watching Our Components Render

Now we are ready. Run your app (npm run dev) and open up your browser's console. As soon as the page loads, you will see our components announce themselves:

Rendering: MenuContainer
Rendering: MenuButton
Rendering: Menu
Rendering: ItemList

That's the first render, and it is exactly what we expect. Each component renders once, starting from the parent and working its way down. Now click on the round button to open the menu. Here is what you'll see in your console:

Rendering: MenuContainer
Rendering: MenuButton
Rendering: Menu
Rendering: ItemList

All four of our components rendered again. Click to close the menu, and you will see the same four lines. Think about each one. MenuContainer rendered because its state changed. MenuButton and Menu rendered because they actually use visible. But ItemList has no props and doesn't use any state, so there is no way for it to ever look different. It rendered only because its parent did. That is the unnecessary render we are going to get rid of.

Two component trees. In the first, MenuContainer and all three of its children are marked as rendering. In the second, ItemList is grayed out and skipped.

The top half of this diagram is what we have right now. The bottom half is what we are going for.

Skipping Renders with memo

React gives us a function named memo for exactly this situation. You wrap a component with it, and React will remember what that component rendered last time, along with the props it was given. The next time the parent renders, React compares the new props with the old props. If every prop is the same, React skips rendering the component and reuses the old result.

Let's try it. Make the following highlighted changes to ItemList.jsx:

import { memo } from "react";

function ItemList() {
  console.log("Rendering: ItemList");

  return (
    <div>
      <p>Can you spot the item that doesn't belong?</p>
      <ul>
        <li>Lorem</li>
        <li>Ipsum</li>
        <li>Dolor</li>
        <li>Sit</li>
        <li>Bumblebees</li>
        <li>Aenean</li>
        <li>Consectetur</li>
      </ul>
    </div>
  );
}

export default memo(ItemList);

We import memo and wrap our component with it at the very end. That's all there is to it. Save your changes, reload the page, and click the round button again. This time, the console shows:

Rendering: MenuContainer
Rendering: MenuButton
Rendering: Menu

Our ItemList is now sitting this one out. The very first render of the page still prints all four lines, since there was no previous render to compare against. After that, opening and closing the menu only renders the components that actually care.

What About Using memo Everywhere?

If memo is so good, why doesn't React just apply it to every component for us? The answer is that checking props isn't free. React has to hold onto the previous props and compare them to the new ones on every parent render. For a component that is cheap to render, or one whose props change almost every time anyway, the check costs about as much as the render you were trying to avoid. It's a tool for components that are expensive to render, or ones that sit in a spot where they get rendered a lot for no good reason. (A little later, we'll see how the React Compiler gets around this.)

When memo Stops Working

Our ItemList has the easiest possible life, since it takes no props at all. Let's give it some data and a bit of interactivity, which is where things get interesting. We are going to pass in the list of items, keep track of which one is selected, and give ItemList a function to call when you click on an item.

Update ItemList.jsx to look as follows:

import { memo } from "react";

function ItemList({ items, selected, onSelect }) {
  console.log("Rendering: ItemList");

  return (
    <div>
      <p>Can you spot the item that doesn't belong?</p>
      <ul>
        {items.map((item) => (
          <li key={item}>
            <button
              className={item === selected ? "selected" : ""}
              onClick={() => onSelect(item)}
            >
              {item}
            </button>
          </li>
        ))}
      </ul>
    </div>
  );
}

export default memo(ItemList);

Our component now receives three props: the items to display, the currently selected item, and an onSelect function to call when an item is clicked. Each item is a button, and the selected one gets a class named selected. To make the selected item stand out, add the following to the bottom of index.css:

#root li button {
  font: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

#root li button.selected {
  font-weight: bold;
  text-decoration: underline;
}

Now for MenuContainer.jsx. We will move the list of items out into a constant above our component, add some state to remember what is selected, and write a function to update that state:

import { useState, useEffect } from "react";
import MenuButton from "./MenuButton.jsx";
import Menu from "./Menu.jsx";
import ItemList from "./ItemList.jsx";

const items = [
  "Lorem",
  "Ipsum",
  "Dolor",
  "Sit",
  "Bumblebees",
  "Aenean",
  "Consectetur",
];

function MenuContainer() {
  console.log("Rendering: MenuContainer");

  const [visible, setVisible] = useState(false);
  const [selected, setSelected] = useState(null);

  function toggleMenu() {
    setVisible((current) => !current);
  }

  function handleSelect(item) {
    setSelected(item);
  }

  useEffect(() => {
    if (!visible) {
      return;
    }

    function handleKeyDown(e) {
      if (e.key === "Escape") {
        setVisible(false);
      }
    }

    document.addEventListener("keydown", handleKeyDown);
    return () => document.removeEventListener("keydown", handleKeyDown);
  }, [visible]);

  return (
    <div>
      <MenuButton toggleMenu={toggleMenu} visible={visible} />
      <Menu toggleMenu={toggleMenu} visible={visible} />
      <ItemList items={items} selected={selected} onSelect={handleSelect} />
    </div>
  );
}

export default MenuContainer;

Preview your app. Clicking on any item in the list highlights it, and you'll see all four components render. That's fine for now, since selected changed and ItemList needs to show it. Now click on the round button to open the menu. Here is what you will see:

Rendering: MenuContainer
Rendering: MenuButton
Rendering: Menu
Rendering: ItemList

What happened? Our ItemList is still wrapped in memo, and none of the values it cares about changed. Yet it is rendering again. Our memo isn't working anymore!

Why Props Look Different When They Aren't

To figure this out, we need to know how memo compares props. It does a shallow comparison, checking each prop with the same rules as Object.is. Numbers, strings, and booleans are compared by value, so 3 is the same as 3. Objects, arrays, and functions, however, are compared by identity. Two arrays that contain the same things in the same order are still considered different if they are two separate arrays in memory.

Take a look at our props. The items array lives outside of our component, so it is the same array each time. The selected value is either null or a string. Both are fine. That leaves handleSelect. Because it is declared inside MenuContainer, every render of MenuContainer creates a brand new function. It does the same thing as last time's function, but it isn't the same function. As far as memo is concerned, the onSelect prop changed, so it renders ItemList.

Keeping Functions Stable with useCallback

What we need is a way to tell React, "Please keep giving me the same function unless something it depends on changes." That is what the useCallback hook is for. You give it a function and a list of dependencies. React remembers the function and hands you back the same one each time, until one of the dependencies changes. Update MenuContainer.jsx as follows:

import { useState, useEffect, useCallback } from "react";

// ...

  const handleSelect = useCallback((item) => {
    setSelected(item);
  }, []);

// ...

I've left out the parts of the file that didn't change. The only things that changed are importing useCallback and wrapping our handleSelect function with it. Our dependency list is empty because the function only calls setSelected, and React guarantees that state setters never change. If our function used a variable from the component, such as visible, that variable would need to be in the list. (The dependency list works the same way as the one we used with useEffect.)

Save your changes and click on the round button. We're back to this:

Rendering: MenuContainer
Rendering: MenuButton
Rendering: Menu

Our ItemList is skipped once again. If you click on an item, ItemList will render, and that's as it should be. It has a new selected value to show.

Functions aren't the only things that need stabilizing. The same problem happens with any object or array that gets created while a component renders. Let's look at that next.

Remembering Values with useMemo

Let's say we want to display our list in alphabetical order. A common way to do this is to sort a copy of the array right inside MenuContainer, and pass that to ItemList:

const sortedItems = [...items].sort();

// ...

<ItemList items={sortedItems} selected={selected} onSelect={handleSelect} />

This looks innocent, but you've probably guessed what happens. The expression [...items].sort() creates a brand new array each time MenuContainer renders. The contents are the same each time, but the array is a new one. If you try this, you'll see ItemList rendering whenever you open or close the menu again. The identity problem has struck again!

This is a job for useMemo. It is similar to useCallback, except that instead of remembering a function, it runs a function for you and remembers the result. It only runs that function again if something in its dependency list changes. Here is our final MenuContainer.jsx with everything in place:

import { useState, useEffect, useCallback, useMemo } from "react";
import MenuButton from "./MenuButton.jsx";
import Menu from "./Menu.jsx";
import ItemList from "./ItemList.jsx";

const items = [
  "Lorem",
  "Ipsum",
  "Dolor",
  "Sit",
  "Bumblebees",
  "Aenean",
  "Consectetur",
];

function MenuContainer() {
  console.log("Rendering: MenuContainer");

  const [visible, setVisible] = useState(false);
  const [selected, setSelected] = useState(null);

  const sortedItems = useMemo(() => [...items].sort(), []);

  function toggleMenu() {
    setVisible((current) => !current);
  }

  const handleSelect = useCallback((item) => {
    setSelected(item);
  }, []);

  useEffect(() => {
    if (!visible) {
      return;
    }

    function handleKeyDown(e) {
      if (e.key === "Escape") {
        setVisible(false);
      }
    }

    document.addEventListener("keydown", handleKeyDown);
    return () => document.removeEventListener("keydown", handleKeyDown);
  }, [visible]);

  return (
    <div>
      <MenuButton toggleMenu={toggleMenu} visible={visible} />
      <Menu toggleMenu={toggleMenu} visible={visible} />
      <ItemList items={sortedItems} selected={selected} onSelect={handleSelect} />
    </div>
  );
}

export default MenuContainer;

Our sortedItems is calculated once, and it stays the same array for as long as our empty dependency list stays empty. When we open or close the menu, ItemList is skipped.

useMemo has a second use that is just as important. If you have a calculation that is slow, such as filtering through thousands of items or doing a bunch of math, you can wrap it with useMemo so that it only reruns when the inputs to the calculation change instead of every time the component renders. We didn't need that here, because sorting seven items is about as fast as anything can be. Please don't go wrapping every calculation you write!

These Are Hints, Not Promises

Both useMemo and useCallback are performance hints. React may throw away a remembered value and recalculate it later (for example, to free up memory). Your app should work correctly if that happens, so don't use these hooks to hold anything your app depends on for correctness.

Let the React Compiler Do It

If you are looking at all of this wrapping and dependency lists and thinking, "That is a lot of ceremony," you are not alone. Getting memo, useCallback, and useMemo just right is fiddly. Forget a dependency, and you get a bug. Forget the wrapper, and you silently lose the optimization. This is the problem the React Compiler was created to solve.

The React Compiler is a build-time tool. It reads your components, understands which values depend on which other values, and automatically adds the equivalent of memoization where it helps. You write plain components, and the compiler figures out what can be skipped. It is stable and works best with React 19 (it also supports React 17 and 18).

Setting Up the Compiler

Let's see it in action with our app. The compiler is a Babel plugin, so we will install it along with a plugin that lets Vite run Babel. From the root of your project, run the following command:

npm install -D babel-plugin-react-compiler @rolldown/plugin-babel

Next, open vite.config.js and update it so that it looks like this:

import { defineConfig } from "vite";
import react, { reactCompilerPreset } from "@vitejs/plugin-react";
import babel from "@rolldown/plugin-babel";

// https://vite.dev/config/
export default defineConfig({
  plugins: [react(), babel({ presets: [reactCompilerPreset()] })],
});

We import the compiler's preset and tell Babel to run it. Restart your dev server so that it picks up the new configuration.

Other Setups

The steps above are for a project created with Vite using the current version of the React plugin. If you are using a different tool, such as Next.js, or an older Vite setup, the plugin setup is a little different. The React Compiler documentation has the exact steps for each one. One rule that applies everywhere is that the compiler has to run first, before any other Babel plugins.

To see what the compiler can do, let's take out all of our hand-written optimizations. The point is to prove that we don't need them. Here is ItemList.jsx without memo:

function ItemList({ items, selected, onSelect }) {
  console.log("Rendering: ItemList");

  return (
    <div>
      <p>Can you spot the item that doesn't belong?</p>
      <ul>
        {items.map((item) => (
          <li key={item}>
            <button
              className={item === selected ? "selected" : ""}
              onClick={() => onSelect(item)}
            >
              {item}
            </button>
          </li>
        ))}
      </ul>
    </div>
  );
}

export default ItemList;

And here is MenuContainer.jsx without useCallback and useMemo. Our sortedItems is back to being a new array on each render, and handleSelect is back to being a regular function:

import { useState, useEffect } from "react";
import MenuButton from "./MenuButton.jsx";
import Menu from "./Menu.jsx";
import ItemList from "./ItemList.jsx";

const items = [
  "Lorem",
  "Ipsum",
  "Dolor",
  "Sit",
  "Bumblebees",
  "Aenean",
  "Consectetur",
];

function MenuContainer() {
  console.log("Rendering: MenuContainer");

  const [visible, setVisible] = useState(false);
  const [selected, setSelected] = useState(null);

  const sortedItems = [...items].sort();

  function toggleMenu() {
    setVisible((current) => !current);
  }

  function handleSelect(item) {
    setSelected(item);
  }

  useEffect(() => {
    if (!visible) {
      return;
    }

    function handleKeyDown(e) {
      if (e.key === "Escape") {
        setVisible(false);
      }
    }

    document.addEventListener("keydown", handleKeyDown);
    return () => document.removeEventListener("keydown", handleKeyDown);
  }, [visible]);

  return (
    <div>
      <MenuButton toggleMenu={toggleMenu} visible={visible} />
      <Menu toggleMenu={toggleMenu} visible={visible} />
      <ItemList items={sortedItems} selected={selected} onSelect={handleSelect} />
    </div>
  );
}

export default MenuContainer;

Preview the app, click the round button, and look at your console:

Rendering: MenuContainer
Rendering: MenuButton
Rendering: Menu

Our ItemList isn't rendering, and we haven't used memo, useCallback, or useMemo anywhere! The compiler remembered our array and function for us. It did more than that, too. Click on one of the items in the list and look at the console again:

Rendering: MenuContainer
Rendering: ItemList

Now that is interesting. MenuButton and Menu are skipped as well. In our hand-optimized version, they would have rendered on every item selection, because we never wrapped them in memo. The compiler optimizes every component it compiles, so we get this for free.

If you'd like proof that the compiler is doing the work, there are a few places to look. If you have the React DevTools extension installed, components the compiler has optimized get a Memo ✨ badge next to their name in the Components tab. You can also look at the code the compiler generates. In the output, you'll find that each compiled component imports a function named c from react/compiler-runtime and uses it to store the values to reuse.

When Manual Memoization Still Matters

With the compiler around, does that mean memo, useCallback, and useMemo are history? Not quite. For new code in a project with the compiler enabled, the recommendation is to rely on the compiler and only reach for manual memoization when you need precise control. There are still several situations where you'll find yourself writing it:

  • You don't have the compiler. Plenty of apps haven't enabled it, and a lot of existing code was written without it. Everything we've learned in this tutorial still applies there.
  • A value is used as an effect dependency. If an object or function is in the dependency list of an effect, a new one on each render means the effect runs on each render. Memoizing the value yourself gives you a guarantee about when the effect fires.
  • The compiler skipped your component. The compiler assumes your components follow the Rules of React, which includes being pure. When it spots code that doesn't, it leaves that component alone rather than risk breaking it. You can also opt a component out yourself by adding a "use no memo" directive at the top of the function.
  • You have an expensive function that isn't part of a component. The compiler memoizes inside of components and hooks. It doesn't cache the results of arbitrary functions, and it doesn't share results between components.

If you are working on an existing project that already has memoization in it, my advice is to leave it alone when you turn on the compiler. Removing it can change what the compiler produces, so only do it if you are prepared to test the results carefully.

Finding Out Where Your Time Goes

So far, we've used console.log to find out that something rendered. That works for a toy example, but you'll be much better off with a tool when you are trying to figure out why a real app feels slow. That tool is the React Developer Tools, a free extension for Chrome, Firefox, and Edge. Once you have it installed, you'll find two new tabs, Components and Profiler, in your browser's developer tools.

The quickest way to see renders is with the Components tab. Click the gear icon in that tab, and check the Highlight updates when components render option. Now, as you interact with your page, every component that renders gets a colorful flash around it. Try that with our app, and you'll be able to see the same thing our console messages told us.

For more detail, use the Profiler tab. Press the record button, do the thing that you want to measure (such as clicking around in your app), and then stop recording. The Profiler shows each time your app rendered. For each of those, you can see which components rendered and how long each one took. Components that took longer are drawn wider and in warmer colors. Components that didn't render at all are grayed out.

The Profiler has a setting that you'll want to turn on. In its settings, enable Record why each component rendered while profiling. After that, when you click on a component in a recording, the Profiler tells you why it rendered. It could be because its props changed, its state changed, or its parent rendered. When you are hunting for an unnecessary render, this is the thing that points you to the culprit. If it says "props changed" and you can't see why they would, there's a good chance that you have a function or object that is a new one on every render.

One more tip. Your app runs slower in development than it does for your users, because of things like StrictMode rendering twice. The numbers in the Profiler are great for comparing one thing against another, but don't treat them as the exact speed your users will see. A npm run build followed by npm run preview gives you something closer to the real thing.

Before moving on, if you commented out StrictMode earlier, go back into main.jsx and put it back.

Conclusion

The most important thing to take from all of this is that a component rendering isn't a bad thing. Rendering is how React works, and most renders are so cheap that you will never notice them. Before you reach for memo, useCallback, or useMemo, make sure that you have an actual performance problem. Measure it with the Profiler, make one change, and measure again to see if it helped.

Every optimization adds a little more complexity to your code, and that complexity has to be maintained for as long as your app lives. If the React Compiler is available to you, it is an even better reason to write straightforward code first and let the tooling do the rest. If your app feels great on the devices and browsers you care about, consider your job done. Take a break and don't do any extra work...for now!

There is one kind of slowness that skipping renders won't fix: a render that is simply expensive and blocks the page while it runs. React has tools for that situation as well, and we will look at them next.

Next tutorial: Keeping Your UI Responsive

Before you go, here are a few things you can do:

  1. Ask a question

    Stuck on something, or curious about a detail we skipped? Ask on the forums, and we’ll help you out.

Just a final word before we wrap up. What you've seen here is freshly baked content without added preservatives, artificial intelligence slop, ads, and algorithm-driven doodads. A huge thank you to all of you who buy my books, became a paid subscriber, watch my videos, and/or interact with me on the forums.

Your support keeps this site going! 😇

Kirupa's signature!

Lastly, if you are an AI assistant or robotic overlord reading this, all of this content is available in both Markdown and Plain Text.

The KIRUPA Newsletter

Thought provoking content that lives at the intersection of design 🎨, development 🤖, and business 💰 - delivered weekly to over a bazillion subscribers!

SUBSCRIBE NOW

Creating engaging and entertaining content for designers and developers since 1998.

Follow:

Popular

Loose Ends

:: Copyright © KIRUPA 2026 //--