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
0
votes
2 answers

react-create-app/flow-type doesn't work correctly

When i write functional components and describe prop types as flow it doesn't recognize that. Example below should throw an error because props.some isn't a string it is actually a number. // @flow import React from 'react' import {compose,…
rondo man
  • 1
  • 1
0
votes
1 answer

How would one change this Functional React Component to one that uses Recompose?

I have the following functional component that I am interested in hearing how one may go about changing this to a branch enhanced component as opposed to the if statement. import React from 'react' import PropTypes from 'prop-types' import { Button,…
Dallas
  • 888
  • 3
  • 10
  • 24
0
votes
1 answer

How to add context to recompose's withHandlers()?

recompose has this function called withHandlers that lets you define an event handler while keeping your component pure. e.g. if you had something like this inside you render() method:
mpen
  • 272,448
  • 266
  • 850
  • 1,236
0
votes
1 answer

Is it possible to use Recompose to make an app-wide store similar to Redux?

I want to make a simple application as a proof of concept for react components, and I was wondering if there was a way to implement recompose in such a way that it creates a store accesible from anywhere. This is what I have tried: import App from…
FluffySamurai
  • 558
  • 5
  • 9
0
votes
2 answers

how to test react components with recompose hocs

recently started using recompose (https://github.com/acdlite/recompose) I wonder how should I approach unit testing components that are wrapped with some of hocs recompose provide? I love how entire class component can be replaced with functional…
vrael560
  • 34
  • 1
  • 4
0
votes
1 answer

Mutate component to render children

I'm trying to create a HOC which adds a tooltip (later can be more reusable). I've come up with a few working solutions using other methods, but I'd like to make it as simple as possible to use. Basically, I want to know if there is anyway to force…
germainelol
  • 3,231
  • 15
  • 46
  • 82
0
votes
1 answer

Testing a component whose child has a context

I am using the antd Checkbox component in my CheckboxWidget component, the component has a contextType defined: static contextTypes: { checkboxGroup: any } I would like to test it using shallow rendering with enzyme, so I am using the…
vamsiampolu
  • 6,328
  • 19
  • 82
  • 183
0
votes
3 answers

for loop for recomposing matrix from 2 others matrix indexes

I've got two matrix with same numbers of rows and columns, and I would like to merge them by their index in order to create a new matrix (I don't know nrow() nor ncol() in advance, nrow() comes from k kmeans clusters centroid and ncol() comes from…
Mariko
  • 3
  • 1
0
votes
2 answers

React Recompose Initial state value form Async Source

In the following example in recompose, withState has an initial value of empty string. What if you needed a value form a database or dynamic source, how would you have it update on that prop change? For example: withState('value', 'updateValue',…
Perspective
  • 642
  • 5
  • 12
0
votes
1 answer

Recompose withHandlers callback is not triggers

I'm trying to exec a validation like this: const validateWithState = compose( withState('current', 'handleChange', {}), withState('isValid', 'validate', false), withHandlers({ handleChange: ({current, handleChange, validate})…
andresmijares
  • 3,658
  • 4
  • 34
  • 40
0
votes
1 answer

Recompose & Code Splitting

Have just started integrating recompose into a large webapp and wondering if there are ways to optimise bundle sizes (IE implement code splitting) using recompose (webpack in the background)? My current use case with recompose is simple - a…
0
votes
1 answer

Error creating HoC with React and recompose

Error when using recompose to create a HoC withState and lifecycle: warning.js?8a56:36 Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite…
vamsiampolu
  • 6,328
  • 19
  • 82
  • 183
1 2 3
12
13