Skip to content

Instantly share code, notes, and snippets.

@vzaidman
Last active September 19, 2020 08:40
Show Gist options
  • Save vzaidman/ccc879acdd99e09e6a416e29313cb760 to your computer and use it in GitHub Desktop.
Save vzaidman/ccc879acdd99e09e6a416e29313cb760 to your computer and use it in GitHub Desktop.
const Main = React.memo(({onClick, style, children, items}) => {
const content = getContent({items});
return (
<div style={style} onClick={onClick}>
{content}
{children}
</div>
);
})
const mainStyle = {width: '100%'};
export const App = () => {
const onMainClick = React.useCallback(() => console.log('click'), []);
const mainItems = React.useMemo(() => ["a", "b"], []);
const mainChildren = React.useMemo(() => <div>hi!<div>, []);
return (
<Main
style={mainStyle}
onClick={onMainClick}
items={mainItems}
>
{mainChildren}
</Main>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment