Chrome Extension

Map State to Props using React + Redux

import React from "react";
import { connect } from "react-redux";

const mapStateToProps = state => {
    return { articles: state.articles };
}

const ConnectedList = ({ articles }) => (
    <ul>
        { articles.map(article => (
            <li className="item" key={article.id}>{ article.title }</li>
        )) }
    </ul>
);

const List = connect(mapStateToProps)(ConnectedList);


class FirstComponent extends React.Component {
    render() {
        return (
            <div>
                <div className="Hello">Hello ankit this i</div>
                <List></List>
            </div>
        );
    }
}

export default FirstComponent;
We are a bunch of lazy programmers so we developed this chrome extension
search code from your favorite search engine
Install Now

The code snippet describes the process of connecting redux state data to React components. We are using the article list to show on Blog page using this code.

Was this helpful?
0 Comments
Open Code Manager We are hiring