项目作者: developit

项目描述 :
:loop: Preact integration for Redux (no shim needed!)
高级语言: JavaScript
项目地址: git://github.com/developit/preact-redux.git
创建时间: 2016-06-02T03:28:15Z
项目社区:https://github.com/developit/preact-redux

开源协议:MIT License

下载


preact-redux

NPM
travis-ci

Wraps react-redux up for Preact (8.x and prior), without using preact-compat. Think of this as a version of react-redux that is pre-aliased to use preact in place of React.

See preact-redux-example: a full working example of redux + preact using preact-redux!

💁‍ Compatibility Note:

If you’re using Preact X (preact@10+), please use the official react-redux library.


Usage Example

This is a contrived example. Please refer to Redux’s Usage with React documentation for details on how to work with Redux from Preact.

  1. import { Provider, connect } from 'preact-redux';
  2. import { h, render } from 'preact';
  3. const Main = () => (
  4. <Provider store={store}>
  5. <Child ></Child>
  6. </Provider>
  7. );
  8. const Child = connect(
  9. state => state
  10. )( ({ text, setText }) => (
  11. <input value={text} onInput={e => setText(e.target.value)} />
  12. ) );
  13. render(<Main ></Main>, document.body);

License

MIT