0.1.1 • Published 3 years ago

@mozaikjs/react v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

@mozaikjs/react

Vue plugin for work with mozaikjs

Install

npm i @mozaikjs/react

or

yarn add @mozaikjs/react

Usage

index.js

import ReactDOM from 'react-dom'
import { StoreProvider } from '@mozaikjs/react'
import { types } from '@mozaikjs/core'

const rootStore = types
  .model('rootStore', {
    name: types.string
  })
  .actions({
    setName({ dispatch }, name) {
      dispatch({
        name
      })
    }
  })
  .create({
    name: 'test'
  })

ReactDOM.render(
  <React.StrictMode>
    <StoreProvider store={rootStore}>
      <App />
    </StoreProvider>
  </React.StrictMode>,
  document.getElementById('root')
)

App.jsx

import { useStore } from './mozaik-react'

function App() {
  const store = useStore()
  return (
    <div className="App">
      <h1>Store name: {store.name}</h1>
      <button onClick={() => store.setName('arthur')}>set name</button>
    </div>
  )
}

export default App
0.1.1

3 years ago

0.1.0

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago