Skip to content

Instantly share code, notes, and snippets.

@thomasJang
Created January 28, 2019 02:21
Show Gist options
  • Save thomasJang/9ee6986cdd6775fa31e1202c1fc3dc03 to your computer and use it in GitHub Desktop.
Save thomasJang/9ee6986cdd6775fa31e1202c1fc3dc03 to your computer and use it in GitHub Desktop.
Filter.tsx
import * as React from "react";
import styled from "styled-components";
import { Input, Icon } from "antd";
const Container = styled.div`
margin: 10px auto;
padding: 0 10px;
`;
export interface IFilterProps {
filter?: string;
width?: number;
onChange?: (filter: string) => void;
}
export default class Filter extends React.Component<IFilterProps> {
render() {
const { filter, width, onChange } = this.props;
return (
<Container style={{ width }}>
<Input
defaultValue={filter}
suffix={
filter ? (
<Icon
type="close"
onClick={() => {
onChange("");
}}
/>
) : null
}
onChange={e => {
onChange(e.target.value);
}}
/>
</Container>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment