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
26
votes
5 answers

Using compose() and connect() together in React JS redux

I am starting to develop a web application using React JS. I bought a theme from theme forest. In the theme, they are using compose like this in the component. ...Other code here Login.propTypes = { classes: PropTypes.shape({}).isRequired, …
Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372
20
votes
1 answer

Typescript: change function type so that it returns new value

Basically, I want something like this: export type ReturnValueMapper any, ReturnValue> = (...args: Args[]) => ReturnValue; I'm almost sure that it's impossible, but I haven't found exact…
Leonid Fenko
  • 203
  • 1
  • 2
  • 5
15
votes
1 answer

How do I setState within React's recompose's lifecycle method?

I am using recompose in my React project https://github.com/acdlite/recompose/ It's a great library. I'm using the compose utility as a container component that passes state down as props to the presentational component like so: const enhance =…
Mark Shust at M.academy
  • 6,300
  • 4
  • 32
  • 50
13
votes
2 answers

How to use recompose's toClass HOC to add a ref to a functional component?

I'm trying to add a ref to a functional component in React Native as to use scrollToEnd on the FlatList component. I would like to use recompose for this and as their docs state, toClass() should be able to handle this. However, no examples are…
13
votes
3 answers

How do you add refs to functional components using withHandlers in Recompose and call ScrollTo on a ScrollView?

My specific goal is to use the ScrollTo method of a ScrollView but maintain functional component structure. More generally this requires getting ref to the current component which isn't possible with naked react native. In Dec 2016 recompose added…
GollyJer
  • 23,857
  • 16
  • 106
  • 174
10
votes
2 answers

Reusable react-redux container components

In my React/Redux app I am often facing with the problem of implementing components with state which should be used throughout the app. Let's take simple popup component as an example with open/close state which can be reused in any page. Here is…
Eugene Gluhotorenko
  • 3,094
  • 2
  • 33
  • 52
8
votes
1 answer

React HOC DOM properties are triggering 'Unknown event handler property'

I just made a HOC with recompose but for some reason all the props passed down are triggering a React Warning. Warning: Unknown event handler property `onSaveChanges`. It will be ignored. And all my property which has the same syntax (starting with…
Istvan Orban
  • 1,607
  • 3
  • 18
  • 34
7
votes
2 answers

How to convert from recompose to hooks?

My company is using recompose as our state management tool. We are refactoring our application to use hooks. For the code below, how would you replace recompose component with react hook components? I understand that withState becomes useState, such…
Darron
  • 323
  • 4
  • 14
7
votes
3 answers

why and when use recompose branch?

I've searched around and after reading some stuff, I still didn't get when I use recompose branch over if-else statement in react or why even use it? can anyone mention a good source or explain it? thanks
Reza Sam
  • 1,264
  • 2
  • 14
  • 29
7
votes
1 answer

How to test the handlers in withHandlers, branch and withState of recompose with enzyme?

I'm new to enzyme testing and I've made a component as : import React from 'react'; import { compose, withState, withHandlers, branch, pure, renderComponent, } from 'recompose'; import Fields from './components/Fields'; import Flow…
Ajay Gaur
  • 5,140
  • 6
  • 38
  • 60
7
votes
1 answer

Testing recompose's HOC with enzyme

How can I test (with jest+enzyme) the following code that uses recompose for creating a HoC: import {compose, withState, withHandlers} from 'recompose' const addCounting = compose( withState('counter', 'setCounter', 0), withHandlers({ …
dotintegral
  • 918
  • 1
  • 10
  • 23
7
votes
2 answers

recompose withHandlers ... asynchronously?

Is is possible/safe to use withHandlers with promises? Ex.: withHandlers({ onChange: props => event => { props.callAPI(props.data) .then(data => props.updateData(data)) }, ... Thanks!
DavidC
  • 147
  • 10
6
votes
1 answer

In JetpackCompose we see all built in composables have flatten inputs,is it with purpose? or wrapping the inputs with data class has same performance?

In Jetpack Compose we see all built in composable have flattened inputs, is it intended? Or wrapping too many inputs with data class (which is good and clean practice) has the same performance? Consider this sample data class SettingsItemEntity( …
6
votes
1 answer

Recompose pure() vs React.PureComponent

What's the difference between pure() from the Recompose library and React.PureComponent? I'm guessing they are essentially solving the same problem. Can someone please clarify this?
avatarhzh
  • 2,175
  • 4
  • 21
  • 32
6
votes
2 answers

use recompose in redux

I have a component which is developed using react and redux. Now that i want to use recompose, I did not understand the organized way to use it with the redux. By organized way, I mean to say before i used to have two function like mapStateToProps…
Serenity
  • 3,884
  • 6
  • 44
  • 87
1
2 3
12 13