Skip to content

Commit

Permalink
Merge pull request #17 from byte-fe/develop
Browse files Browse the repository at this point in the history
docs(v1.1.0): Update Docs for new release.
  • Loading branch information
ArrayZoneYour authored Dec 31, 2018
2 parents d493d47 + 5dcd2d1 commit 20327a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
30 changes: 4 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,7 @@ The State management library for React

## Quick Start

Running demo

```
git clone https://github.com/byte-fe/react-modelx.git
cd react-model/example
npm i
npm run initial
npm run dev
```
[Next.js + react-modelx work around](https://github.com/ArrayZoneYour/react-modelx-experiment)

install package

Expand All @@ -30,8 +22,6 @@ npm install react-modelx

react-model keep the state and actions in a global store. So you need to register them before using.

`index.ts`

```typescript
import { Model } from 'react-modelx'
import Home from '../model/home.model'
Expand All @@ -42,18 +32,6 @@ const models = { Home, Shared }
export const { useStore } = Model(models)
```

`index.js`

```javascript
import { Model } from 'react-modelx'
import Home from '../model/home.model'
import Shared from '../model/shared.model'

const models = { Home, Shared }

export const { useStore } = Model(models)
```

### useStore

The functional component in React 16.7 can use Hooks to connect the global store.
Expand Down Expand Up @@ -102,7 +80,7 @@ type ActionsParamType = {
get: undefined
} // You only need to tag the type of params here !

const Model = {
const Model: ModelType<StateType, ActionsParamType> = {
actions: {
increment: async (state, _, params) => {
return {
Expand Down Expand Up @@ -133,7 +111,7 @@ const Model = {
}
},
state: initialState
} as ModelType<StateType, ActionsParamType> // The Modal actions type will generate automatically by the StateType and ActionParamsType
}

export default Model

Expand Down Expand Up @@ -205,7 +183,7 @@ JavaScript Example
const Model = {
actions: {
increment: async (s, _, params) => {
return (state: typeof s) => {
return state => {
state.counter += params || 1
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-modelx",
"version": "1.0.6",
"version": "1.1.0",
"description": "The State management library for React",
"main": "./dist/index",
"module": "./dist/index",
Expand Down

0 comments on commit 20327a2

Please sign in to comment.