1.1.3 • Published 4 months ago

@growthops/ext-react v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

GrowthOps Ext React

codecov

A collection of useful components, helpers, and extensions for React projects.

Utilities

useState

import {useState} from '@growthops/ext-react';

This is a wrapper around React's standard useState hook, offering out of the box integration with Ramda's evolve function. There is one notable difference however in this case, any non-function value passed in will be assigned as-is, while functions will be executed with the current state (object) value as you would expect with Ramda's evolve function.

Example 1

import React from 'react';
import {useState} from '@growthops/ext-react';
import {inc} from 'ramda';

const Example = () = {
	const {state, setState} = useState({counter: 0});

	const incrementCounter = () => setState({counter: inc});

	return (
		<button type="button" onClick={incrementCounter}>Increment</button>
	);
};

export default Example;

Example 2

import React from 'react';
import {useState} from '@growthops/ext-react';

const Example = () = {
	const {state, setState} = useState({counter: 0});

	const setCounterToFortyTwo = () => setState({counter: 42});

	return (
		<button type="button" onClick={setCounterToFortyTwo}>Set</button>
	);
};

export default Example;
1.1.3

4 months ago

1.1.1

3 years ago

1.0.2

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago