Gathering detailed insights and metrics for concent
Gathering detailed insights and metrics for concent
Gathering detailed insights and metrics for concent
Gathering detailed insights and metrics for concent
concent-test
control your react component state in a funny way, every react instance of different class if they were registered in concent own the ability of knowing and syncing each other's state, just have a try and discover more^_^
react-router-concent
let using react-router more easily in concent
concent-plugin-loading
a plugin for control your loading state
concent-utils
Utils for helping concent make common functions in ts project
A reactive atomic state engine for React(including React 18) and all React like, carrying dependency collection feature, supporting fine-grained updates.
npm install concent
Typescript
Module System
Node Version
NPM Version
72.9
Supply Chain
94.7
Quality
77.1
Maintenance
100
Vulnerability
100
License
TypeScript (96.68%)
JavaScript (3.29%)
Shell (0.03%)
Total Downloads
246,369
Last Day
5
Last Week
67
Last Month
2,054
Last Year
19,337
MIT License
1,374 Stars
1,931 Commits
70 Forks
18 Watchers
17 Branches
5 Contributors
Updated on May 15, 2025
Minified
Minified + Gzipped
Latest Version
2.21.9
Package Id
concent@2.21.9
Unpacked Size
1.66 MB
Size
355.49 kB
File Count
371
NPM Version
8.19.4
Node Version
16.20.0
Published on
Aug 26, 2024
Cumulative downloads
Total Downloads
Last Day
0%
5
Compared to previous day
Last Week
-11.8%
67
Compared to previous week
Last Month
-16%
2,054
Compared to previous month
Last Year
-4.2%
19,337
Compared to previous year
3
52
English | 简体中文
⚡️ State management that tailored for react, it is simple, predictable, progressive and efficient.
Concent is an amazing state management tool, supported by a healthy middleware ecosystem and excellent devtools. It is a predictable, zero-invasive, progressive, high-performance react development framework!
Concent encourages simplicity. It saves you the hassle of creating boilerplate code and gives powerful tools with a moderate learning curve, suitable for both experienced and inexperienced developers alike.
recommend next verion lib: helux
A best practise project(git) building by concent & typescript.
1$ git clone https://github.com/tnfe/concent-pro (dev with webpack) 2$ git clone https://github.com/tnfe/vite-concent-pro (dev with vite)
Install by npx command
1$ npx create-react-app my-app --template concent-ts
or clone its source code by git command
1$ git clone https://github.com/concentjs/cra-project-concent-ts
Visit official website https://concentjs.github.io/concent-doc to learn more.
Make sure you have installed nodejs。
1$ npm i --save concent
or yarn command
1$ yarn add concent
See how easy it is to use concent to manage react state.
1import { run, register, useConcent } from 'concent'; 2 3// 1️⃣ Configure models 4run({ 5 counter: {// declare a moudle named 'counter' 6 state: { num: 1, numBig: 100 }, // define state 7 }, 8 // you can also put another module here. 9}); 10 11// 2️⃣ Now the react component can work with concent 12@register('counter') // 👈 decorate your component with register 13class DemoCls extends React.Component{ 14 // commit state to store and broadcast to other refs which also belong to counter module 15 inc = ()=> this.setState({num: this.state.num + 1}) 16 render(){ 17 // here if read num, it means current ins render dep keys is ['num'] 18 return <button onClick={this.inc}>{this.state.num}</button> 19 } 20} 21function DemoFn(){ 22 const { state, setState } = useConcent('counter'); // 👈 call useConcent hook in fn component 23 const inc = ()=> setState({num: state.num + 1}); 24 return <button onClick={inc}>{state.num}</button> 25}
Move logic to
reducer
and definecomputed
,watch
,lifecycle
try edit this demo、 👉better js demo、👉better ts demo
1import { run, register, useConcent, defWatch } from 'concent'; 2 3run({ 4 counter: { 5 state: { num: 1, numBig: 100 }, 6 computed: { 7 numx2: ({ num }) => num * 2, // only num changed will trigger this fn 8 numx2plusBig: ({ numBig }, o, f) => f.cuVal.numx2 + numBig // reuse computed reslult 9 }, 10 reducer: { 11 initState: () => ({ num: 8, numBig: 800 }), 12 add: (payload, moduleState, actionCtx) => ({ num: moduleState.num + 1 }), 13 addBig: (p, m, ac) => ({ numBig: m.numBig + 100 }), 14 asyncAdd: async (p, m, ac) => { 15 await delay(1000); 16 return { num: m.num + 1 }; 17 }, 18 addSmallAndBig: async (p, m, ac) => { 19 // hate string literal? see https://codesandbox.io/s/combine-reducers-better-7u3t9 20 await ac.dispatch("add"); 21 await ac.dispatch("addBig"); 22 } 23 }, 24 watch: { 25 numChange: defWatch(({ num }, o) => console.log(`from ${o.num} to ${num}`), {immediate:true}), 26 numChangeWithoutImmediate: ({ num }, o) => console.log(`from ${o.num} to ${num}`), 27 }, 28 lifecycle: { 29 // loaded: (dispatch) => dispatch("initState"), // [optional] triggered when module loaded 30 // initState: async (moduleState) => {/** async logic */ return{num:666}}, // [optional] allow user load state async 31 // initStateDone: (dispatch) => dispatch("addSmallAndBig"), // [optional] call any reducer fn after initState done 32 mounted: (dispatch) => dispatch("initState"), // [optional] triggered when the first ins of counter module mounted 33 willUnmount: (dispatch) => dispatch("initState") // [optional] triggered when the last ins of counter module unmount 34 } 35 } 36}); 37 38@register("counter") 39class DemoCls extends React.Component { 40 render() { 41 // mr is short of moduleReducer, now you can call counter module's all reducer fns by mr 42 return <button onClick={this.ctx.mr.add}>{this.state.num}</button>; 43 } 44} 45 46function DemoFn() { 47 const { moduleComputed, mr } = useConcent("counter"); 48 return <button onClick={mr.add}>numx2plusBig: {moduleComputed.numx2plusBig}</button>; 49}
Details see here react-router-concent,expose history
,you can call it anywhere in your app to enjoy the imperative navigation jump.
react-router-concent online demo
Details see here concent-plugin-redux-devtool,track your state changing history。
Details see here concent-plugin-loading,control all your reducer function's loading status easily。
concent-plugin-loading online demo
cdn.bytedance
https://cdn.bytedance.com/?query=concent
![]() ![]() |
![]() wink |
concent is released under the MIT License. http://www.opensource.org/licenses/mit-license
No vulnerabilities found.
No security vulnerabilities found.