preact-socrates

1.0.2 • Public • Published

preact-socrates

Preact plugin for socrates.

Install

npm install preact-socrates

Example

import { render, h } from 'preact-socrates'
import Logger from 'redux-logger'
import Socrates from 'socrates'
 
/**
 * Create our virtual dom tree
 */
 
const Home = ({ dispatch, greeting }) => (
  <div class='home'>
    <h2>{ greeting }</h2>
    <button onClick={(e) => dispatch('change greeting', { greeting: 'Hey bud' })}>Change the greeting</button>
  </div>
)
 
/**
 * Initialize our store
 */
 
let store = Socrates([
  Logger()
])
 
/**
 * Initial application state
 */
 
store('boot', {
  greeting: 'Welcome to the website, friend!'
})
 
/**
 * Render our virtual dom tree to the <body>
 */
 
render(Home, store, document.body)

License

MIT

Dependents (0)

Package Sidebar

Install

npm i preact-socrates

Weekly Downloads

2

Version

1.0.2

License

none

Last publish

Collaborators

  • mattmueller