-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avec combine store non mutable
- Loading branch information
Showing
4 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { MemeSVGViewer } from 'orsys-tjs-meme'; | ||
import MemeForm from '../../components/functionnal/MemeForm/MemeForm'; | ||
|
||
function MemeEditor(props) { | ||
|
||
return (<> | ||
<MemeSVGViewer meme={meme} image={imgs.find((img) => img.id === meme.imageId)} basePath='' /> | ||
<MemeForm meme={meme} images={imgs} onMemeChange={(meme) => { | ||
setmeme(meme); | ||
}} /> | ||
</> | ||
) | ||
} | ||
|
||
MemeEditor.propTypes = { | ||
id: PropTypes.number, | ||
} | ||
|
||
export default MemeEditor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
|
||
function MemeThumbnail(props) { | ||
return ( | ||
<div className='MemeThumbnail'> | ||
<MemeSVGThumbnail memes={memes} images={imgs} basePath='' /> | ||
</div> | ||
) | ||
} | ||
|
||
export default MemeThumbnail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { createStore, combineReducers } from "redux" | ||
|
||
export const storeInitialState = { content: '', isShown: false } | ||
|
||
const reducer = (state = storeInitialState, action) => { | ||
console.log(action); | ||
switch (action.type) { | ||
case 'modal/show': | ||
return { ...state, content: action.payload, isShown: true } | ||
case 'modal/hide': | ||
return { ...state, content: '', isShown: false } | ||
default: | ||
return state | ||
} | ||
} | ||
export const store=createStore(combineReducers({modal:reducer,modal2:reducer})); | ||
store.subscribe(()=>{console.log(store.getState())}); | ||
|
||
store.dispatch(showModal('coucou')) | ||
store.dispatch({type:'modal/hide'}) | ||
|
||
export function showModal(content){ | ||
return {type:'modal/show',payload:content} | ||
} |