-
Notifications
You must be signed in to change notification settings - Fork 180
Getting Started
Tyler Shaddix edited this page Feb 22, 2019
·
6 revisions
This package is available on npm:
npm install --save webext-redux
As described in the introduction, there are two pieces to a basic implementation of this package.
// popover.js
import React from 'react';
import {render} from 'react-dom';
import {Provider} from 'react-redux';
import {Store} from 'webext-redux';
import App from './components/app/App';
const store = new Store();
// The store implements the same interface as Redux's store
// so you can use tools like `react-redux` no problem!
render(
<Provider store={store}>
<App/>
</Provider>
, document.getElementById('app'));
// background.js
import {wrapStore} from 'webext-redux';
const store; // a normal Redux store
wrapStore(store);
That's it! The dispatches called from UI component will find their way to the background page no problem. The new state from your background page will make sure to find its way back to the UI components.
The setup above handles basic actions and state updates. To handle more complex async actions and action responses, check out Advanced Usage.
If you want to dive into the details of this package, check out the API.