Skip to content

Commit

Permalink
code example reworked for the talk
Browse files Browse the repository at this point in the history
  • Loading branch information
euZebe committed May 15, 2018
1 parent 2f6ca8f commit 8854bbc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/components/ArticleFormContainer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { connect } from 'react-redux';
import ArticleForm from './ArticleForm';
import { createForm } from '../store/articles';
import { createArticle } from '../store/articles';

const mapStateToProps = () => ({});

const mapDispatchToProps = (dispatch) => ({
createForm: (title, body) => dispatch(createForm(title, body)),
createForm: (title, body) => dispatch(createArticle(title, body)),
});

export default connect(mapStateToProps, mapDispatchToProps)(ArticleForm);
5 changes: 0 additions & 5 deletions src/molkky-vanilla-redux.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
const { createStore } = require('redux');

const action = {
type: 'INIT_SCORES_SHEET',
players: ['Alice', 'Bob']
};

function initGame(players) {
console.log('=> jeu initialisé');
return {
Expand Down
2 changes: 1 addition & 1 deletion src/store/articles.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const FORM_CREATE = 'FORM_CREATE';
/*
* action creators
*/
export const createForm = (title, body) => ({
export const createArticle = (title, body) => ({
type: FORM_CREATE,
payload: {
title,
Expand Down
4 changes: 2 additions & 2 deletions src/store/articles.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createStore } from 'redux';
import deepFreeze from 'deep-freeze';
import { createForm, getArticlesSortedByCreationDate, getLastModification } from './articles';
import { createArticle, getArticlesSortedByCreationDate, getLastModification } from './articles';
import reducers from './reducers';

describe('articles duck', () => {
Expand All @@ -10,7 +10,7 @@ describe('articles duck', () => {
expect(getLastModification(previousState)).toBeNull();
expect(getArticlesSortedByCreationDate(previousState)).toHaveLength(0);

store.dispatch(createForm('mon titre', 'mon contenu'));
store.dispatch(createArticle('mon titre', 'mon contenu'));

const nextState = store.getState();
expect(getLastModification(nextState)).not.toBeNull();
Expand Down

0 comments on commit 8854bbc

Please sign in to comment.