react#memo TypeScript Examples
The following examples show how to use
react#memo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.tsx From ExpressLRS-Configurator with GNU General Public License v3.0 | 7 votes |
CardTitle: FunctionComponent<CardTitleProps> = memo(({ icon, title }) => {
return (
<CardContent>
<Grid container spacing={1} alignItems="center">
<Grid item>{icon}</Grid>
<Grid item flexGrow={1}>
<Typography variant="h6">{title}</Typography>
</Grid>
</Grid>
</CardContent>
);
})
Example #2
Source File: add-photo-alternate.tsx From keycaplendar with MIT License | 5 votes |
MemoSvgAddPhotoAlternate = memo(SvgAddPhotoAlternate)
Example #3
Source File: index.tsx From ExpressLRS-Configurator with GNU General Public License v3.0 | 5 votes |
BuildNotificationsList: FunctionComponent<BuildNotificationsListProps> = memo(
({ notifications }) => {
const toSeverity = (
item: BuildProgressNotificationType
): 'error' | 'info' | 'success' => {
switch (item) {
case BuildProgressNotificationType.Error:
return 'error';
case BuildProgressNotificationType.Info:
return 'info';
case BuildProgressNotificationType.Success:
return 'success';
default:
return 'info';
}
};
// TODO: this should be used for translations
const toText = (step: BuildFirmwareStep): string => {
switch (step) {
case BuildFirmwareStep.VERIFYING_BUILD_SYSTEM:
return 'Verifying build system';
case BuildFirmwareStep.DOWNLOADING_FIRMWARE:
return 'Downloading firmware';
case BuildFirmwareStep.BUILDING_USER_DEFINES:
return 'Building user_defines.txt';
case BuildFirmwareStep.BUILDING_FIRMWARE:
return 'Compiling firmware';
case BuildFirmwareStep.FLASHING_FIRMWARE:
return 'Flashing device';
default:
return '';
}
};
return (
<>
{notifications.map((item, idx) => {
return (
<React.Fragment key={`${idx}-${item.step}`}>
<Alert sx={styles.notification} severity={toSeverity(item.type)}>
{item?.step !== undefined &&
item.step !== null &&
toText(item.step)}
</Alert>
</React.Fragment>
);
})}
</>
);
}
)
Example #4
Source File: ActionAddImage.tsx From atlas with GNU General Public License v3.0 | 5 votes |
Memo = memo(SvgActionAddImage)