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
1
vote
1 answer

How to test functions in component with enzyme, jest, recompose, react

Ok, so I'm a little stumped on how to test my component's functionality using enzyme/jest. Still learning how to test my components - I can write simple tests but now I need to make them more complex. I'd like to know the best way to test that my…
sbcreates
  • 199
  • 2
  • 11
1
vote
1 answer

Recompose passing prop of an array of react elements

I started to use the recompose library, and it works great. But I am having some issues passing a default props of react elements. flow error: call of mapOptions Function cannot be called on array type /* @flow */ import Input, { InputLabel }…
Muffin
  • 31
  • 5
1
vote
3 answers

this.forceUpdate() in recompose withHandler

I want to use this.forceUpdate() in one of the handler named 'update' in withHandlers of my compose. I am using recompose to achieve the same. Find sample code below: const abc = compose( withHandlers( update: () => () =>…
Shyam Kansagra
  • 892
  • 12
  • 24
1
vote
1 answer

With Redux-Form, how to dispatch from a ReduxFormField onChange event?

I'm getting the following error: 'dispatch' is not defined no-undef What I'm trying to do is make it so whenever the user selects one of the ReduxFormField radio buttons, the form auto submits. What is the right way to be able to do this..dispatch…
AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012
1
vote
1 answer

Why is Context not being passed to my HOC

I have a component that is using a HOC. The HOC needs this.context but for some reason this.context is not being passed. What am I doing wrong? ty component: import React, { Component } from 'react'; import withTracking from…
AnnaSm
  • 2,190
  • 6
  • 22
  • 32
1
vote
1 answer

How to write a recompose HOC to User Analytics?

I'm currently sending user analytic tracking events without a HOC like so: import React from 'react'; class NamePage extends Component { componentDidMount() { this.context.mixpanel.track('View Page: NamePage'); } render() { ... …
AnnaSm
  • 2,190
  • 6
  • 22
  • 32
1
vote
1 answer

Using react-with-styles in recompose

Can someone help me with an example of applying styles using react-with-styles in a higher order component using recompose ? Specifically, how can we apply styles as explained in this example -- https://github.com/airbnb/react-with-styles#how-to-use…
stackoverflowN
  • 447
  • 6
  • 21
1
vote
1 answer

Recompose multiple renderComponent

I have a recompose filter that needs to render two components and pass props from a redux connect to the second component However the code below never renders the second renderComponent - which is a real shame. Is there a way to get the below…
azz0r
  • 3,283
  • 7
  • 42
  • 85
1
vote
1 answer

Recompose : Equivalant of the combination withState/withHandlers with withStateHandlers

Simple question: if i want to use withStateHandlers instead of the couple withState/withHandlers. What is the equivalant of this : withState('value', 'updateValue', ''), withHandlers({ onChange: ({updateValue}) => event =>…
wyeo
  • 33
  • 5
1
vote
1 answer

How can I use state inside recompose's `withPropsOnChange` HOC?

I want to use withPropsOnChange to create a new debounced function based on the props that were passed in. If the props are changed, it should create a new function. withPropsOnChange seems perfect for this, except that I need access to this.state…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
1
vote
1 answer

Which way do props flow with compose()?

Consider the following: const Foo = defaultProps({ foo: "foo" }); compose( Foo, LoadJson, RunParser )(Bar); In this case, does the prop foo flow down through LoadJson->RunParser->Bar? Or is it in reverse order, where foo flows…
davidkomer
  • 3,020
  • 2
  • 23
  • 58
1
vote
1 answer

withState vs. withStateHandlers

The docs @ https://github.com/acdlite/recompose/blob/master/docs/API.md#withstate says this regarding withState You'll likely want to use this state updater along with withHandlers() to create specific updater functions. Then it has a separate…
davidkomer
  • 3,020
  • 2
  • 23
  • 58
1
vote
1 answer

How do I export an enhanced component?

I have a common folder with several components and an index.js file that looks like this: export * from './Alert' export * from './Button' ... I do this so I can import them like this: import { Alert, Button } from './common' In each of those…
Javid Jamae
  • 8,741
  • 4
  • 47
  • 62
1
vote
1 answer

How to get wrapped component instance with recompose?

I'm using lifecycle to create a Higher-Ordered Component. I need access to the wrapped component instance. How can I get it? e.g. export default function ajaxLoader(options) { return lifecycle({ componentWillMount() { // how…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
1
vote
2 answers

React Native Recompose action not triggering reducer

I'm working on setting up a user login screen in React Native using Recompose, with separate actions and reducer files, but my reducer is never being called. Currently, there is just a login button that triggers a doUserLogin() recompose…
Bob T
  • 318
  • 2
  • 8