mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-63138 Fix some console warnings (#30209)
* Fix forwardRef propTypes console error The console error that was fixed by this is: "Warning: forwardRef render functions do not support propTypes or defaultProps. Did you accidentally pass a React component?" * Fix function component ref console error This fixes the following error: Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React. forwardRef ()?
This commit is contained in:
@@ -75,7 +75,7 @@ type Props = {
|
|||||||
focus: (newPosition: number) => void;
|
focus: (newPosition: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SearchInput = ({searchTerms, searchType, setSearchTerms, onKeyDown, focus}: Props, inputRef: React.Ref<HTMLInputElement>) => {
|
const SearchInput = forwardRef<HTMLInputElement, Props>(({searchTerms, searchType, setSearchTerms, onKeyDown, focus}, inputRef) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
let searchPlaceholder = intl.formatMessage({id: 'search_bar.search', defaultMessage: 'Search'});
|
let searchPlaceholder = intl.formatMessage({id: 'search_bar.search', defaultMessage: 'Search'});
|
||||||
|
|
||||||
@@ -131,6 +131,6 @@ const SearchInput = ({searchTerms, searchType, setSearchTerms, onKeyDown, focus}
|
|||||||
)}
|
)}
|
||||||
</SearchInputContainer>
|
</SearchInputContainer>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
export default forwardRef<HTMLInputElement, Props>(SearchInput);
|
export default SearchInput;
|
||||||
|
@@ -15,7 +15,7 @@ exports[`components/threading/channel_threads/thread_footer should match snapsho
|
|||||||
isFollowing={true}
|
isFollowing={true}
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
>
|
>
|
||||||
<Memo(Button)
|
<Button
|
||||||
className="separated FollowButton"
|
className="separated FollowButton"
|
||||||
disabled={false}
|
disabled={false}
|
||||||
isActive={true}
|
isActive={true}
|
||||||
@@ -32,7 +32,7 @@ exports[`components/threading/channel_threads/thread_footer should match snapsho
|
|||||||
Following
|
Following
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</Memo(Button)>
|
</Button>
|
||||||
</Memo(FollowButton)>
|
</Memo(FollowButton)>
|
||||||
</div>
|
</div>
|
||||||
</Memo(ThreadFooter)>
|
</Memo(ThreadFooter)>
|
||||||
@@ -317,7 +317,7 @@ exports[`components/threading/channel_threads/thread_footer should report total
|
|||||||
</WithTooltip>
|
</WithTooltip>
|
||||||
</div>
|
</div>
|
||||||
</Memo(Avatars)>
|
</Memo(Avatars)>
|
||||||
<Memo(Button)
|
<Button
|
||||||
className="ReplyButton separated"
|
className="ReplyButton separated"
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
prepend={
|
prepend={
|
||||||
@@ -363,13 +363,13 @@ exports[`components/threading/channel_threads/thread_footer should report total
|
|||||||
</FormattedMessage>
|
</FormattedMessage>
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</Memo(Button)>
|
</Button>
|
||||||
<Memo(FollowButton)
|
<Memo(FollowButton)
|
||||||
className="separated"
|
className="separated"
|
||||||
isFollowing={true}
|
isFollowing={true}
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
>
|
>
|
||||||
<Memo(Button)
|
<Button
|
||||||
className="separated FollowButton"
|
className="separated FollowButton"
|
||||||
disabled={false}
|
disabled={false}
|
||||||
isActive={true}
|
isActive={true}
|
||||||
@@ -386,7 +386,7 @@ exports[`components/threading/channel_threads/thread_footer should report total
|
|||||||
Following
|
Following
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</Memo(Button)>
|
</Button>
|
||||||
</Memo(FollowButton)>
|
</Memo(FollowButton)>
|
||||||
<Connect(injectIntl(Timestamp))
|
<Connect(injectIntl(Timestamp))
|
||||||
day="numeric"
|
day="numeric"
|
||||||
@@ -828,7 +828,7 @@ exports[`components/threading/channel_threads/thread_footer should show unread i
|
|||||||
</WithTooltip>
|
</WithTooltip>
|
||||||
</div>
|
</div>
|
||||||
</Memo(Avatars)>
|
</Memo(Avatars)>
|
||||||
<Memo(Button)
|
<Button
|
||||||
className="ReplyButton separated"
|
className="ReplyButton separated"
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
prepend={
|
prepend={
|
||||||
@@ -874,13 +874,13 @@ exports[`components/threading/channel_threads/thread_footer should show unread i
|
|||||||
</FormattedMessage>
|
</FormattedMessage>
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</Memo(Button)>
|
</Button>
|
||||||
<Memo(FollowButton)
|
<Memo(FollowButton)
|
||||||
className="separated"
|
className="separated"
|
||||||
isFollowing={true}
|
isFollowing={true}
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
>
|
>
|
||||||
<Memo(Button)
|
<Button
|
||||||
className="separated FollowButton"
|
className="separated FollowButton"
|
||||||
disabled={false}
|
disabled={false}
|
||||||
isActive={true}
|
isActive={true}
|
||||||
@@ -897,7 +897,7 @@ exports[`components/threading/channel_threads/thread_footer should show unread i
|
|||||||
Following
|
Following
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</Memo(Button)>
|
</Button>
|
||||||
</Memo(FollowButton)>
|
</Memo(FollowButton)>
|
||||||
<Connect(injectIntl(Timestamp))
|
<Connect(injectIntl(Timestamp))
|
||||||
day="numeric"
|
day="numeric"
|
||||||
|
@@ -18,18 +18,22 @@ type Props = {
|
|||||||
|
|
||||||
type Attrs = Exclude<ButtonHTMLAttributes<HTMLButtonElement>, Props>
|
type Attrs = Exclude<ButtonHTMLAttributes<HTMLButtonElement>, Props>
|
||||||
|
|
||||||
function Button({
|
const Button = React.forwardRef<HTMLButtonElement, Props & Attrs>((
|
||||||
prepend,
|
{
|
||||||
append,
|
prepend,
|
||||||
children,
|
append,
|
||||||
isActive,
|
children,
|
||||||
hasDot,
|
isActive,
|
||||||
marginTop,
|
hasDot,
|
||||||
allowTextOverflow = false,
|
marginTop,
|
||||||
...attrs
|
allowTextOverflow = false,
|
||||||
}: Props & Attrs) {
|
...attrs
|
||||||
|
},
|
||||||
|
ref,
|
||||||
|
) => {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
|
ref={ref}
|
||||||
{...attrs}
|
{...attrs}
|
||||||
className={classNames('Button Button___transparent', {'is-active': isActive, allowTextOverflow}, attrs.className)}
|
className={classNames('Button Button___transparent', {'is-active': isActive, allowTextOverflow}, attrs.className)}
|
||||||
>
|
>
|
||||||
@@ -49,6 +53,7 @@ function Button({
|
|||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
Button.displayName = 'Button';
|
||||||
|
|
||||||
export default memo(Button);
|
export default memo(Button);
|
||||||
|
@@ -5,7 +5,7 @@ exports[`components/threading/common/follow_button should say follow 1`] = `
|
|||||||
isFollowing={false}
|
isFollowing={false}
|
||||||
onClick={[MockFunction]}
|
onClick={[MockFunction]}
|
||||||
>
|
>
|
||||||
<Memo(Button)
|
<Button
|
||||||
className="FollowButton"
|
className="FollowButton"
|
||||||
disabled={false}
|
disabled={false}
|
||||||
isActive={false}
|
isActive={false}
|
||||||
@@ -22,7 +22,7 @@ exports[`components/threading/common/follow_button should say follow 1`] = `
|
|||||||
Follow
|
Follow
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</Memo(Button)>
|
</Button>
|
||||||
</Memo(FollowButton)>
|
</Memo(FollowButton)>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ exports[`components/threading/common/follow_button should say following 1`] = `
|
|||||||
<Memo(FollowButton)
|
<Memo(FollowButton)
|
||||||
isFollowing={true}
|
isFollowing={true}
|
||||||
>
|
>
|
||||||
<Memo(Button)
|
<Button
|
||||||
className="FollowButton"
|
className="FollowButton"
|
||||||
disabled={false}
|
disabled={false}
|
||||||
isActive={true}
|
isActive={true}
|
||||||
@@ -45,6 +45,6 @@ exports[`components/threading/common/follow_button should say following 1`] = `
|
|||||||
Following
|
Following
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</Memo(Button)>
|
</Button>
|
||||||
</Memo(FollowButton)>
|
</Memo(FollowButton)>
|
||||||
`;
|
`;
|
||||||
|
Reference in New Issue
Block a user