PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.14.3
GiveWP – Donation Plugin and Fundraising Platform v4.14.3
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / DonationForms / resources / app / utilities / memoNode.ts
memoNode.ts
20 lines 704 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {memo} from '@wordpress/element';
2 import {Node} from '@givewp/forms/types';
3
4 /**
5 * This is used for memoizing Node components. Node props come from the server and are never intended to change. The
6 * state of a Node may change, triggering a re-render, but the props should never change.
7 *
8 * @since 3.3.0 updated param and return types
9 * @since 3.0.0
10 */
11 export default function memoNode(NodeComponent: {({node}: {node: Node}): JSX.Element}): typeof NodeComponent {
12 return memo(NodeComponent, compareNodeProps) as typeof NodeComponent;
13 }
14
15 type NodeProp = {node: Node};
16
17 function compareNodeProps(oldNode: NodeProp, newNode: NodeProp) {
18 return oldNode.node.name === newNode.node.name;
19 }
20