Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Apr 4, 2022
1 parent de9543f commit fc0fa43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions components/lib/card/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { classNames, ObjectUtils } from '../utils/Utils';

export const Card = React.forwardRef((props, ref) => {

const elementRef = useRef(ref);
const elementRef = React.useRef(ref);

const createHeader = () => {
if (props.header) {
Expand All @@ -29,15 +29,15 @@ export const Card = React.forwardRef((props, ref) => {
)
}

React.useEffect(() => {
ObjectUtils.combinedRefs(elementRef, ref);
}, [elementRef, ref]);

const otherProps = ObjectUtils.findDiffKeys(props, Card.defaultProps);
const className = classNames('p-card p-component', props.className);
const header = createHeader();
const body = createBody();

useEffect(() => {
ObjectUtils.combinedRefs(elementRef, ref);
}, [elementRef, ref]);

return (
<div id={props.id} ref={elementRef} className={className} style={props.style} {...otherProps}>
{header}
Expand Down
4 changes: 2 additions & 2 deletions components/lib/panel/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { classNames, IconUtils, ObjectUtils, UniqueComponentId } from '../utils/
export const Panel = React.forwardRef((props, ref) => {
const [idState, setIdState] = React.useState(props.id);
const [collapsedState, setCollapsedState] = React.useState(props.collapsed);
const elementRef = useRef(ref);
const elementRef = React.useRef(ref);
const contentRef = React.useRef(null);
const collapsed = props.toggleable ? (props.onToggle ? props.collapsed : collapsedState) : false;
const headerId = idState + '_header';
Expand Down Expand Up @@ -44,7 +44,7 @@ export const Panel = React.forwardRef((props, ref) => {
props.onCollapse && props.onCollapse(event);
}

useEffect(() => {
React.useEffect(() => {
ObjectUtils.combinedRefs(elementRef, ref);
}, [elementRef, ref]);

Expand Down

0 comments on commit fc0fa43

Please sign in to comment.