Questions tagged [recompose]

Recompose is a React utility belt for function components and higher-order components. Think of it like lodash for React.

Recompose is a React utility belt for function components and higher-order components. Think of it like lodash for React.

You can use Recompose to

  • lift state into functional wrappers
  • perform the most common React patterns
  • optimize rendering performance
  • interoperate with other libraries
  • build your own libraries

Useful Links

Related tags

192 questions
4
votes
0 answers

recompose withStateHandlers and TypeScript, implementation type leaks to component?

I am trying to wrap a stateless functional component with withStateHandlers from recompose. I'm finding the only way I can do this is if I tweak my SFC's props to match some aspects of withStateHandlers that "leaks" out. Am I doing something wrong…
Matt Greer
  • 60,826
  • 17
  • 123
  • 123
4
votes
1 answer

Testing recompose with enzyme - accessing props issue

So I've searched for an answer and have yet to find one that fits my use case. I'm a little new to testing with Jest/Enzyme and very new to testing with recompose. I don't know how to test my functional Component, which is created using recompose. I…
sbcreates
  • 199
  • 2
  • 11
4
votes
1 answer

Why do all the Recompose recipes start with "const { Component } = React;"

Why do all the Recompose recipes start with const { Component } = React; when they don't use Component, or do they? What's the significance of starting the recipe like that? https://github.com/acdlite/recompose/wiki/Recipes
Simon C
  • 436
  • 4
  • 11
4
votes
1 answer

Example of async with recompose()?

I have the following code which works completely, though one part of it (_FetchJSON) is a custom HOC outside of recompose (live demo @ https://codepen.io/dakom/pen/zdpPWV?editors=0010) const LoadingView = () =>
Please wait...
; const…
davidkomer
  • 3,020
  • 2
  • 23
  • 58
4
votes
1 answer

How to pass the initial state as props for my Higher Order Component?

I have a Slider component that doesn't handle its own state, instead, it's wrapped in another component called SliderDrag that manages the state and passes down props to the Slider I'm using withState from recompose library to achieve that. here is…
3
votes
1 answer

Correct Typing for HigherOrderComponents with recompose and typescript

I'm currently trying to get recompose into my react codebase. Therefore I was trying to get some basic things working, and I got it working, but I'm not really sure, if this is the correct way recompose is intended to work. So I have following…
Azael
  • 614
  • 4
  • 16
3
votes
1 answer

How to pass event handlers to React-node in React-Recompose App

Got working App at: https://github.com/BeerDRinker/recompose-ref Following code(commented part in /src/App.js) works as expected: class App extends Component { constructor(props) { super(props); this.node = React.createRef(); this.state…
Ros
  • 47
  • 1
  • 5
3
votes
0 answers

React recompose: async setState > explanation needed

Using recompose to load data async as shown below, and in this question, my question is: -Why does setState(payload) not work within componentDidMount? The reson I am asking is that it still eludes me, and it is such a pitfall. const contextTypes =…
Gnimmelf
  • 137
  • 2
  • 9
3
votes
1 answer

How to get flow to typecheck props given to it from a HOC?

For example: import { withProps } from 'recompose' type Props = { name: string, }; const NameTag = ({ name }: Props) => (

{ name }

); const MyNameTag = withProps({ // i want a error here name:…
Nathan K.
  • 55
  • 7
3
votes
2 answers

React, Redux and Recompose: "dispatch is not a function"

I've got a container/component (from Redux examples) complaining about "dispatch is not a function". I had this working before I added Recompose. I think Recompose puts a wrapper around dispatch(), so I need to expose it somehow. Maybe…
Big Daddy
  • 5,160
  • 5
  • 46
  • 76
3
votes
1 answer

Recompose withProps

I am trying to get my head around on how recompose works. Although I understand the underlying concept of it I have a problem with using withProps function. If I try using it for decorating each child of a component with additional props it simply…
SOReader
  • 5,697
  • 5
  • 31
  • 53
3
votes
1 answer

Can't change the state withStateHandlers from recompose

I have this button and playing around withStateHandlers from recompose. The goal is just to change button state from active: false to active: true. const EnhancedButton = withStateHandlers( ({ initialState = false }) => ({ active:…
karolis2017
  • 2,195
  • 8
  • 24
  • 49
3
votes
0 answers

REACT.JS Managing state in a component vs react route (Link) best practices

I wanted to know what the best way to handle my situation would be. I have two Link components that each pass a different variable in state through to the next Component. Depending on the state being passed, the Component conditionally renders…
sbcreates
  • 199
  • 2
  • 11
3
votes
2 answers

How should I test the composition of React components using HOCs (or should I even test them at all)?

Testing components with HOCs generally seems to be a major problem (enzyme#539, enzyme#1002, recompose#407, ...). Most discussions include the opinion "test only the HOC as a function and then later not the usage", whereby for unit tests the actual…
Putzi San
  • 5,566
  • 3
  • 19
  • 35
3
votes
0 answers

Get url params in mapStateToProps when using recompose compose in reactjs

I have this URL: /user/Jd5Egbh... I use react-router-dom for navigation. I have made a UserDetails component. I use mapStateToProps to get url params like this: function mapStateToProps({ users }, ownProps) { return { user:…
1 2
3
12 13