cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

              //Import any modules from libraries
const { Provider, connect } = ReactRedux;
const { applyMiddleware, createStore, combineReducers, bindActionCreators } = Redux;
const CHANGE_MESSAGE = 'change_message';

//This is the Action Creator
let changeMessage = function(message) { 
  let newMessage;
  if(message=='First Message') {
    newMessage = 'Second Message';
  } else {
    newMessage = 'First Message';
  //return an action
  return {
    payload: newMessage

//Our reducer
let messageReducer = function(state={}, action) {

  switch(action.type) {
      return action.payload;
      return state;

//This is the final reducer that gets attached to our store.
const rootReducer = combineReducers ({

  message: messageReducer

//create the store
let store = createStore(rootReducer);

//Component one is a button
class ReduxButton extends React.Component {
  onClick(e) {
  render() {
        <button onClick={this.onClick.bind(this)}>Press Button</button>

//Second component is a text field
class ReduxTextField extends React.Component {
  render() {

    if(typeof this.props.message == "object") {
      return (<div>First Message</div>);
    } else {

//map our the state's message to this property on the components
let mapStateToProps = function(state) {
    return { message: state.message };

//give these components access to the change message creator
let mapDispatchToProps = function(dispatch) {
  return bindActionCreators({changeMessage}, dispatch)

//Make the two components Redux Containers
const ReduxButtonContainer = connect(mapStateToProps, mapDispatchToProps)(ReduxButton);
const ReduxTextFieldContainer = connect(mapStateToProps, null)(ReduxTextField);

//Create teh app component which contains the button and text field
class App extends React.Component {
  render() {
    return (
        <ReduxTextFieldContainer />
        <ReduxButtonContainer />

//Finally render to DOM!
ReactDOM.render(<Provider store={store}><App/></Provider>, document.getElementById('root'));
Loading ..................