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.

[Solved] Using with Redux

See original GitHub issue

Hello I am trying to use this library with Redux, but I have to click two times on the color in order to get it displayed (I try with CirclePicker), but the action is dispatched on the first click as expected.

How can I get the good color displayed on the first click ? And why does it work at the second one ?

I call it like

<CirclePicker style={{"margin":"0 auto"}} onChangeComplete={createCategoryColor} />

And the method called simply does createCategoryColor(color, event){ const { dispatch } = this.props; dispatch(selectColorCreate(color.hex)); }

Do you have any idea please ? This lib is really nice !

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
casesandbergcommented, Apr 5, 2017

You also have to pass the active color down into the component:

<div className={styles.row} style={{width:'50%'}}>
  <label>{label}</label>
  <SliderPicker color={ FIELD_NAME_HEX_COLOR_VAR } onChange={ (color) => { props.change(fieldName, color.hex) } } /> 
  <Field name={fieldName} component="hidden" /> 
</div>
0reactions
pradeepgill007commented, Oct 24, 2017

Hi @casesandberg the problem is still there as I have to click two times on the color in order to get it displayed.

`const colorSlider = ({ input, label, meta: { touched, error }, …custom }) => (<div style={{width:‘50%’}}> <BlockPicker {…input} {…custom}/>

</div> )`

<Field color={item.value} triangle="hide" colors={['#000', '#ff0000']} item={item} name={item.key} component={colorSlider}/>

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is redux and what problem does it solve? - Stack Overflow
1 Answer 1 · Basically, redux allow you to save data into a "store" which can be accessed by all of your components...
Read more >
Understanding Redux: A tutorial with examples
In this tutorial, we'll show you what Redux is, why you should use it, and how it works. We'll demo using a simple...
Read more >
Still don't understand why you need Redux? Read this...
Redux provides a solution by ensuring that: Your state is wrapped in a store which handles all updates and notifies all code that...
Read more >
Redux Fundamentals, Part 5: UI and React
The official Redux Fundamentals tutorial: learn how to use Redux with React. ... One possible solution to this is to change how useSelector ......
Read more >
What Problems Does Redux solve with React? | by Zack Grooms
What Problems Does Redux solve with React? · 1. INCREASES PREDICTABILITY. The state becomes predictable in the Redux library. · 2. IT OPTIMIZES...
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