'asUploadButton' causing React warning
See original GitHub issueUsing asUploadButton
like in the example causing the following warning in the console:
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Check the render method of `ForwardRef(AsUploadButton)`.
in Unknown (created by ForwardRef(AsUploadButton))
Versions Uploady 0.5.0 React 16.13.1
Code
import React, { useState } from 'react'
import ChunkedUploady, {
useBatchStartListener,
useBatchFinishListener
} from '@rpldy/chunked-uploady'
import { asUploadButton } from '@rpldy/upload-button'
import { Button } from 'antd'
import { UploadOutlined } from '@antd-design/icons'
const UploadButton = asUploadButton(props => {
const [visible, setVisible] = useState(true)
useBatchStartListener(() => {
setVisible(false)
})
useBatchFinishListener(() => {
setVisible(true)
})
return visible ? (
<Button shape="circle" {...props}>
<UploadOutlined />
</Button>
) : null
})
const Upload = (props) => {
return (
<ChunkedUploady
destination={{
url: props.url
}}
multiple={props.multiple}
withCredentials={true}
params={props.params}
accept={props.accept}
>
<UploadButton />
</ChunkedUploady>
)
}
export default Upload
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
How You Can Fix The Biggest Problem With React File Upload
This quick tutorial will teach you how to enable a React file upload on Filestack. Start by creating a basic form and submit...
Read more >How to run an alert on button click React.js - Stack Overflow
handleUploadImage(ev) { alert("Your file is being uploaded! ... from 'react' import { Alert } from 'react-alert' class Main extends React.
Read more >How to Use a Simple Form Submit with Files in React
Uploading images or files is a major function of any app. It is an essential requirement for creating a truly full-stack app.
Read more >Create Custom File Upload button control reactjs jsx - YouTube
reactjscustomfileuploadCreating customizing file upload control in reactjs component with simple button and image html element.
Read more >React File Uploader With Express (Using React Hooks)
In this project we will build a full stack file upload with React and Express. We will construct the UI with a Bootstrap...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Look in UploadButton.js Where is a correct example of usage asUploadButton.
done.