React bindings for @github/file-attachment-element
npm install react-file-attachmentbash
npm install react-file-attachment
or yarn
yarn add react-file-attachment
or pnpm
pnpm add react-file-attachment
`
Usage
#### Plain
`jsx
import FileAttachment from 'react-file-attachment';
const App = () => {
return (
Your tips here
)
}
`
#### specifying the file types
`jsx
import FileAttachment from 'react-file-attachment';
const App = () => {
return (
>
Your tips here
)
}
`
#### render accepted file names
`jsx
import FileAttachment from 'react-file-attachment';
const App = () => {
return (
{
return fileNames.map((n) => {n})
}}
>
Your tips here
)
}
`
#### styling the element
`jsx
import FileAttachment from 'react-file-attachment';
const App = () => {
return (
style={{
backgroundColor: '#f5f5f5',
border: '1px solid #e3e3e3',
borderRadius: '4px',
padding: '10px',
cursor: 'pointer',
display: 'inline-block',
margin: '10px',
}}
className="custom-classname"
>
Your tips here
)
}
`
#### events
`tsx
import FileAttachment from 'react-file-attachment';
import type {FileAcceptEvent, FileAcceptEvented} from 'react-file-attachment';
const App = () => {
const onFileAccept = (evt: FileAcceptEvent) => {
console.log(evt.detail.attachments);
}
const onFileAccepted = (evt: FileAcceptedEvent) => {
console.log(evt.detail.attachments);
}
return (
onFileAccept={onFileAccept}
onFileAccepted={onFileAccepted}
>
Your tips here
)
}
``