question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'asUploadButton' causing React warning

See original GitHub issue

Using 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:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
omcg33commented, Sep 17, 2020

Look in UploadButton.js Where is a correct example of usage asUploadButton.

0reactions
yoavnirancommented, Sep 18, 2020
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found