Skip to content

Instantly share code, notes, and snippets.

@aleksnick
Last active March 2, 2026 11:15
Show Gist options
  • Select an option

  • Save aleksnick/494f66e2851bc5483e50b029444d3c82 to your computer and use it in GitHub Desktop.

Select an option

Save aleksnick/494f66e2851bc5483e50b029444d3c82 to your computer and use it in GitHub Desktop.
About hooks
import React from 'react';
import { useSelector } from 'react-redux';
import { customExpensiveSelector } from '@utils';
export default function TestComponent({ obj }) {
if (!obj.someField) {
return null;
}
const value = useSelector(customExpensiveSelector(obj.someField));
return (
<div>{value}</div>;
);
}
@aleksnick
Copy link
Copy Markdown
Author

import React from 'react';
import { useUser } from '@reduxjs/toolkit/query';

export default function TestComponent({ obj }) {
	if (!obj.userId) {
		return null;
	}

	const value = useUser(obj.userId));

	return (
		<div>{value}</div>;
	);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment