How I built a Content Management System for a React app in one day

How to Build a #ContentManagement System in just 1 day!


#JavaScript #React #Reactjs #CMS

  • DYI content management system with Firebase  ReactHow I built a Content Management System for a React app in one dayFirebase + React = Quick DIY CMSThere are two ways of handling website content:Use a CMS.Hard code in the copy/image urls in the code itself.Option number 2 quick at first, and is fine…
  • However, two big problems will surface and grow as companies scale.In fact, I have personally experienced multiple times the first of these two problems at work.Problem 1: time wasted by engineerEvery time there needs to be a content change, the product team would need to ping an engineer, and the engineer…
  • This will definitely be a problem if the company ever goes international in non-English speaking countries.SolutionThe solution to these two problems is a good content management system.Pillow, where I’m currently working, had a Hackathon last week.
  • Anyone can signup for an account with their gmail, create a project, and add data to the database.Because of the NoSQL structure, I thought it would be a great way to store website copy.
  • This is what I did to structure Pillow’s landing page copy during the Hackathon:Screenshot of json data structurePillow’s website is already built with React, and that made my job a lot easier.All I needed to do on that front is install re-base, set up some configuration, and replace the hard…

Option number 2 quick at first, and is fine for an early stage startup operating in one country. However, two big problems will surface and grow as companies scale. Every time there needs to be a…
Continue reading “How I built a Content Management System for a React app in one day”

How to Build a Todo App Using React, Redux, and Immutable.js — SitePoint

  • This helps us get a feel for what we’re going to need our components to render:
    const dummyTodos = [
    { id: 0, isDone: true, text: ‘make components’ },
    { id: 1, isDone: false, text: ‘design actions’ },
    { id: 2, isDone: false, text: ‘implement reducer’ },
    { id: 3, isDone: false, text: ‘connect components’ }
    ];

    For this application, we’re only going to need two React components, Todo / and TodoList /.

  • js

    import React from ‘react’;

    export function Todo(props) {
    const { todo } = props;
    if(todo.isDone) {
    return strike{todo.text}/strike;
    } else {
    return span{todo.text}/span;
    }
    }

    export function TodoList(props) {
    const { todos } = props;
    return (
    div className=’todo’
    input type=’text’ placeholder=’Add todo’ /
    ul className=’todo__list’
    {todos.map(t = (
    li key={t.id} className=’todo__item’
    Todo todo={t} /
    /li
    ))}
    /ul
    /div
    );
    }

    At this point, we can test these components by creating an index.html file in the project folder and populating it with the following markup.

  • /components’;

    const dummyTodos = [
    { id: 0, isDone: true, text: ‘make components’ },
    { id: 1, isDone: false, text: ‘design actions’ },
    { id: 2, isDone: false, text: ‘implement reducer’ },
    { id: 3, isDone: false, text: ‘connect components’ }
    ];

    render(
    TodoList todos={dummyTodos} /,
    the code with npm run build, then navigate your browser to the index.html file and make sure that it’s working.

  • Our dummy data is a great place to start from, and we can easily translate it into ImmutableJS collections:
    import { List, Map } from ‘immutable’;

    const dummyTodos = List([
    Map({ id: 0, isDone: true, text: ‘make components’ }),
    Map({ id: 1, isDone: false, text: ‘design actions’ }),
    Map({ id: 2, isDone: false, text: ‘implement reducer’ }),
    Map({ id: 3, isDone: false, text: ‘connect components’ })
    ]);

    ImmutableJS maps don’t work in the same way as JavaScript’s objects, so we’ll need to make some slight tweaks to our components.

  • The mapStateToProps function takes the store’s current state as an argument (in our case, a list of todos), then it expects the return value to be an object that describes a mapping from that state to props for our wrapped component:
    function mapStateToProps(state) {
    return { todos: state };
    }

    It might help to visualize this on an instance of the wrapped React component:
    TodoList todos={state} /

    We’ll also need to supply a mapDispatchToProps function, which is passed the store’s dispatch method, so that we can use it to dispatch the actions from our action creators:
    function mapDispatchToProps(dispatch) {
    return {
    addTodo: text = dispatch(addTodo(text)),
    toggleTodo: id

Dan Prince shows how to build a Todo app using React, Redux, and Immutable.js.
Continue reading “How to Build a Todo App Using React, Redux, and Immutable.js — SitePoint”

Why build your forms with Redux Form – DailyJS – Medium

Why build your forms with #Redux Form:  #ReactJS

  • Why build your forms with Redux FormWhen I usually create forms for my React/Redux applications I tend to keep the value of the inputs on the application state, with little to no editing, (because my forms are usually simple), I never stopped to realize what that means.
  • It also receives an event handler that will update the state when the user interacts with it.It means that when the user types the letter “J” on the input, what is visible is not the same “J”, it may be an identical “J” that comes from the state, or whatever the event handler has put in there.Ok but, that doesn’t answer the first questionBy having all the application state in the JavaScript app and using controlled components we get a single source of truth and take full control over the application behavior.In the context of a form, our React component is able to:do instant validation;control the input value format;enable, disable, show or hide components given the state;handle dynamic inputs.Although it is highly recommended to use controlled components, it is also good to point the drawback that you will have to create event handlers for all your inputs and that may be a bunch of code that doesn’t make sense to the application.What about Redux Form?Now that is known why to keep the form data in the state and you reason if that makes sense for your application we can come back to our main subject.
  • It keeps track of all common application form state such as:The fields that are in the form;The values of each field;The focused field;If the field values are valid;The fields that the user have interacted with;If the form is being submitted;If is happening any asynchronous validation.Let’s take a look at a bit of code and see how to do a setup.Here we connect the form component to Redux by decorating it with the high-order component reduxForm.
  • It will also hand us the handleSubmit function, which will take care of the submission behavior.The Field component takes our input component as its props and acts as a container, bringing the application state to the input component and binding the event handlers to update the state in store.Look at the InputText component to see the props we receive from the Field.One important point is that it’s still a developer’s responsibility to write the form and inputs components, this way the library does not take the flexibility from you to manage the behaviors of your form the way you want, or even add custom ones.And to finish our integration we add a reducer that will handle the state changes of your form.Simple isn’t it.Just one more point.
  • Look that the default value of the input is defined when the high-order component reduxForm is called and comes to the input within the prop input and not from the react’s prop defaultValue, this way we guarantee that our form values are all represented in the application state.In summary, having all your form data in application state gives you control over its behavior and you can easily implement that on a React/Redux application with Redux Form.I have created a repository on GitHub with the implementation above.

When I usually create forms for my React/Redux applications I tend to keep the value of the inputs on the application state, with little to no editing, (because my forms are usually simple), I never…
Continue reading “Why build your forms with Redux Form – DailyJS – Medium”

Redux middleware logging basics – Ben Garrison – Medium

Redux middleware logging basics  #beer #javascript #middleware #redux #react #reactjs

  • Wouldn’t it be great to be able to go back and look at the exact state of the application at the time of the crash and even the actions that led up to the crash?
  • You would have to spread these things all over your application to catch your store at different phases of change.
  • When you are working on larger apps however, there are advantages to having a single definition point.
  • Let’s see how that may look:You can see above that we have combined 3 middleware:Our new custom loggerRedux Thunk for handling asynch callsRouterMiddleware that captures and redirects actions to your historyYou can combine middleware and they have no need to know about the ‘ware that proceeds or follows them.
  • The moment between the Action and the Reducer is a critical exchange and using middleware to cleanly log state can improve the overall quality of your app.

I have written previously about REDUX and some of its features, if you are interested in a more general introduction, please check out the post below. Implementing this FLUX-style architecture has…
Continue reading “Redux middleware logging basics – Ben Garrison – Medium”

Code your own combineReducers – Jakob Lind

New post! Code your own combineReducers function.  #reactjs #redux #javascript

  • A reducer is a function that takes the Redux state and a Redux Action as input parameters.
  • The combineReducer function call takes an object with reducers.
  • We now have the function combineReducers that accepts reducers as input parameters.
  • As we learned in the beginning in this article, a normal Redux reducer is a function that takes two parameters: state and action.
  • The output after running getState should be an object with all the reducer names as keys and the state as the value.

It’s time for a completely different approach. To master Redux, we will code it from scratch. Today it’s time for the combineReducer function.
Continue reading “Code your own combineReducers – Jakob Lind”

A new approach to managing Redux actions – Medium

A new approach to managing Redux actions:  #ReactJS

  • It needs 3 types of actions: COUNTER_PLUS_ONE, COUNTER_MINUS_ONE, COUNTER_RESET. Then we create 3 actions files (we usually create a redux folder for actions): counterPlusOne.js, counterMinusOne.js, counterReset.js.
  • From the code we can see: the wrapper reducer itself is also a place to write reducers.
  • The wrapper reducer is responsible for loading other reducers defined in different actions, and call them one by one to generate a new state when receiving a new action.
  • Easier to develop: no need to jump between files when creating actions.
  • Whenever creating an action, it usually and immediately needs to create a reducer to handle it to update the store.

I’ve been using Redux for about one year and enjoyed it for creating a pretty large project. Redux really helped a lot for managing the…
Continue reading “A new approach to managing Redux actions – Medium”

Redux: Store Methods: getState(), dispatch(), and subscribe()

#Redux: Store Methods: getState(), dispatch(), and subscribe() by @dan_abramov   #ReactJS

  • We will learn about the Redux Store and demonstrate how its three methods let us implement a counter application.
  • It retrieves the current state of the Redux store .
  • The store binds together the three principles of Redux .
  • I subscribe the render method to this store .
  • The first method of this store is called getState .

Read the full article, click here.


@NaveenS16: “#Redux: Store Methods: getState(), dispatch(), and subscribe() by @dan_abramov #ReactJS”


We will learn about the Redux Store and demonstrate how its three methods let us implement a counter application.


Redux: Store Methods: getState(), dispatch(), and subscribe()