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.

Dropzone not working when custom style using styled-components

See original GitHub issue

Do you want to request a feature or report a bug?

  • I found a bug
  • I want to propose a feature

What is the current behavior?

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention other relevant information such as the browser version, Operating System and react-dropzone version.

const DropzoneStyled = styled(Dropzone) background: ‘#f8f8f8’, border: ‘5px dashed #ddd’, width: ‘100%’, height: ‘50px’, textAlign: ‘center’, paddingTop: ‘25px’ ;

image

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

17reactions
alexcrooxcommented, Jun 27, 2018

This works for me

import React from 'react'
import Dropzone from 'react-dropzone'
import styled, { css } from 'styled-components'

const DropZone = (props) => (
  <Dropzone onDrop={props.onDrop} style={{}}>
    {({ isDragActive, isDragAccept, isDragReject, acceptedFiles, rejectedFiles }) => (
      <DropZoneContainer isDragActive={isDragActive} isDragReject={isDragReject}>
        Drop files here
      </DropZoneContainer>
    )}
  </Dropzone>
)

const DropZoneContainer = styled.div`
  height: 400px;
  border: 2px dashed #2c67d8;
  padding: 30px;

  ${props => (props.isDragActive) && css`
    border-color: green;
  `}
`

export default DropZone

The key was style={{}} on the Dropzone element to stop it from applying it’s own default styles outside of my DropZoneContainer

2reactions
okonetcommented, Jan 3, 2018

Although I recognize this is as a bug, I can’t accept not properly filled issues due to the lack of time. Please provide with a reproducible example or code and fill out the rest of the template and I’ll reopen it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Styling Dropzone
The hook fn doesn't set any styles on either of the prop fns ( getRootProps() / getInputProps() ). Using inline styles. Drag 'n'...
Read more >
React-dropzone style drop area - Stack Overflow
I am new to reactjs , trying to create a component that uses react-dropzone. I was wondering ...
Read more >
Customization - React Dropzone Uploader
Custom Styles. RDU's default styles are defined using CSS. They can be overridden using the classNames and styles props, which expose RDU's simple, ......
Read more >
Create a Drag-and-Drop Zone in React ... - OpenReplay Blog
React-dropzone is a very powerful library and custom component. ... Styling. Although our React-dropzone is working well, it doesn't look ...
Read more >
react-dropzone - npm
Simple HTML5 drag-drop zone with React.js. ... no need for using innerRef as refKey import styled from 'styled-components' const StyledDiv ...
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