Skip to content

Commit

Permalink
perf(app-board): remove arrow function
Browse files Browse the repository at this point in the history
  • Loading branch information
rams23 committed Jan 26, 2021
1 parent 4ca6d2b commit 6509317
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useCallback, useState } from 'react';
import { CollapsibleRuleContent, RuleContent, RuleHeader, RuleWrapper } from './ExpandableRule.styled';
import { Icon, Typography } from '@pipeline/components';
import { ReactComponent as ExpandIcon } from '@assets/icons/accordion-expand.svg';
Expand All @@ -11,9 +11,13 @@ type Props = {
const ExpandableRule: React.FC<Props> = ({ title, children }) => {
const [collapsed, setCollapsed] = useState(true);

const toggle = useCallback(() => {
setCollapsed(c => !c);
}, []);

return (
<RuleWrapper collapsed={collapsed}>
<RuleHeader collapsed={collapsed} p={3} onClick={() => setCollapsed(c => !c)}>
<RuleHeader collapsed={collapsed} p={3} onClick={toggle}>
<Icon>{collapsed ? <ExpandIcon /> : <CollapseIcon />}</Icon>
<Typography variant="title" fontWeight="600">
{title}
Expand Down

0 comments on commit 6509317

Please sign in to comment.