Skip to content

matthewmueller/preact-socrates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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