# give/4.18.0/src/DonationForms/resources/app/utilities/memoNode.ts

GiveWP – Donation Plugin and Fundraising Platform, version 4.18.0. 20 lines.

- Page: https://pluginprobe.com/plugins/give/4.18.0/code/src/DonationForms/resources/app/utilities/memoNode.ts
- Raw: https://pluginprobe.com/plugins/give/4.18.0/raw/src/DonationForms/resources/app/utilities/memoNode.ts
- Modified: 2024-01-10T19:22:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.18.0/code/src/DonationForms/resources/app/utilities/memoNode.ts#L10-L20`.

```typescript
import {memo} from '@wordpress/element';
import {Node} from '@givewp/forms/types';

/**
 * This is used for memoizing Node components. Node props come from the server and are never intended to change. The
 * state of a Node may change, triggering a re-render, but the props should never change.
 *
 * @since 3.3.0 updated param and return types
 * @since 3.0.0
 */
export default function memoNode(NodeComponent: {({node}: {node: Node}): JSX.Element}): typeof NodeComponent {
    return memo(NodeComponent, compareNodeProps) as typeof NodeComponent;
}

type NodeProp = {node: Node};

function compareNodeProps(oldNode: NodeProp, newNode: NodeProp) {
    return oldNode.node.name === newNode.node.name;
}

```
