Git Product home page Git Product logo

use-xf's Introduction

pkg use-xf

use-xf is always-transformed state for React

test status

Installation

yarn add @creatorqsf/use-xf

or

npm install --save @creatorqsf/use-xf

Usage

// import
import { useXf } from '@creatorqsf/use-xf'

useXf( /* transforming function */ fn, /* initial state */ state )

Counter Example with string prefix "count: "

// import
import { useXf } from '@creatorqsf/use-xf'

// ...

  const [state, setState] = useXf( (n: number): string => "count: " + n.toString(), 0)

// ...

  <button onClick={() => setState(10)}>Make counter 10</button>
  <p>{state}</p> <!-- state will be `count: 10` after button clicked -->

1st, 2nd, 3rd, 4th Counter Example

// import
import { useXf } from '@creatorqsf/use-xf'

// ...

  const [state, setState] = useXf( (n: number): "1st" | "2nd" | "3rd" | `${number}th` => {
    switch (n) {
      case 1:
        return "1st"
      case 2:
        return "2nd"
      case 3:
        return "3rd"
      default:
        return `${n}th`
    }
  }, 1)

// ...

  <button onClick={() => setState(2)}>Make counter 2</button>
  <p>{state}</p> <!-- state will be `2nd` after button clicked -->

License

MIT

Author

@Qs-F (たふみ / @CreatorQsF)

use-xf's People

Contributors

dependabot[bot] avatar qs-f avatar renovate-bot avatar renovate[bot] avatar

Watchers

 avatar  avatar

use-xf's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/release.yml
  • actions/checkout v3
  • actions/setup-node v3
.github/workflows/test.yml
  • actions/checkout v3
  • actions/setup-node v3
  • actions/checkout v3
  • actions/setup-node v3
npm
package.json
  • @jest/globals 27.5.1
  • @testing-library/react-hooks 8.0.1
  • @types/jest 27.5.2
  • @types/node 16.11.43
  • @types/react 18.0.15
  • @typescript-eslint/eslint-plugin 5.30.5
  • @typescript-eslint/parser 5.30.5
  • eslint 8.19.0
  • eslint-config-google 0.14.0
  • eslint-config-prettier 8.5.0
  • eslint-import-resolver-typescript 3.2.4
  • eslint-plugin-import 2.26.0
  • eslint-plugin-prettier 4.2.1
  • eslint-plugin-react 7.30.1
  • jest 27.5.1
  • microbundle 0.15.0
  • npm-run-all 4.1.5
  • prettier 2.7.1
  • react 18.2.0
  • react-dom 18.2.0
  • rimraf 3.0.2
  • ts-jest 27.1.5
  • ts-node 10.8.2
  • tsc-alias 1.6.11
  • typescript 4.5.5
  • @types/react ^17.0.18 || ^18.0.0
  • react ^17.0.2 || ^18.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.