Skip to content

Commit

Permalink
docs(register,usage): Update source of import and register method.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArrayZoneYour committed Dec 6, 2018
1 parent a43f2f5 commit 97a721f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
27 changes: 9 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,14 @@ npm install git+https://github.com/byte-fe/react-model.git#master
react-model keep the state and actions in a global store. So you need to register them before using.

```typescript
import { useCallback, useContext, useEffect, useState } from 'react'
import { registerModel } from '../model'
import { registerModel } from 'react-model'
import Home from '../model/home.model'
import Shared from '../model/shared.model'

registerModel(
{
Home,
Shared
},
{
useState,
useCallback,
useEffect,
useContext
}
)
registerModel({
Home,
Shared
})
```

### useStore
Expand All @@ -53,7 +44,7 @@ The functional component in React 16.7 can use Hooks to connect the global store

```javascript
import React from 'react'
import { useStore } from '../model'
import { useStore } from 'react-model'

export default () => {
const [state, actions] = useStore('Home')
Expand All @@ -80,7 +71,7 @@ The global state standalone can not effect the react class components, we need t

```jsx
import { PureComponent } from 'react'
import { Provider } from './model'
import { Provider } from 'react-model'

class App extends PureComponent {
render() {
Expand All @@ -101,7 +92,7 @@ Javascript decorator version

```jsx
import React, { PureComponent } from 'react'
import { Provider, connect } from '../model'
import { Provider, connect } from 'react-model'

const mapProps = ({ light, counter }) => ({
lightStatus: light ? 'open' : 'close',
Expand Down Expand Up @@ -130,7 +121,7 @@ TypeScript Version

```tsx
import React, { PureComponent } from 'react'
import { Provider, connect } from '../model'
import { Provider, connect } from 'react-model'
import { StateType, ActionType } from '../model/home.model'

const mapProps = ({ light, counter, response }: StateType) => ({
Expand Down
2 changes: 1 addition & 1 deletion example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 97a721f

Please sign in to comment.