Reconstruct code
This commit is contained in:
parent
0034589837
commit
fdc1578306
|
@ -1,4 +1,4 @@
|
|||
import React from 'react'
|
||||
import React from "react";
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
function calClassName(selected) {
|
||||
|
@ -6,9 +6,9 @@ function calClassName(selected) {
|
|||
return 'Qr-item';
|
||||
}
|
||||
|
||||
const Style = ({ value, renderer, selected, onClick }) => (
|
||||
const Style = ({ value, renderer, selected, onSelected }) => (
|
||||
<div className={calClassName(selected)}
|
||||
onClick={onClick}>
|
||||
onMouseDown={onSelected}>
|
||||
<div className="Qr-item-image">
|
||||
<div className="Qr-item-image-inner">
|
||||
{renderer}
|
||||
|
@ -24,7 +24,7 @@ Style.propTypes = {
|
|||
value: PropTypes.string.isRequired,
|
||||
renderer: PropTypes.object.isRequired,
|
||||
selected: PropTypes.bool.isRequired,
|
||||
onClick: PropTypes.func.isRequired
|
||||
onSelected: PropTypes.func.isRequired
|
||||
}
|
||||
|
||||
export default Style;
|
||||
|
|
|
@ -8,7 +8,7 @@ const StyleList = ({ styles, onSelected }) => (
|
|||
<Style
|
||||
key={style.value}
|
||||
{...style}
|
||||
onClick={() => onSelected(index)}
|
||||
onSelected={() => onSelected(index)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import {connect} from 'react-redux';
|
||||
import * as React from "react";
|
||||
|
||||
const mapStateToProps = (state, ownProps) => ({
|
||||
qrcode: state.qrcode,
|
||||
|
|
|
@ -36,13 +36,18 @@ const mapStateToProps = state => ({
|
|||
return {
|
||||
value: style.value,
|
||||
selected: state.selectedIndex == index,
|
||||
renderer: React.createElement(Renderer(style.renderer), {index: index, setParamInfo: setParamInfo})
|
||||
renderer: React.createElement(Renderer(style.renderer), {
|
||||
index: index,
|
||||
setParamInfo: setParamInfo
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
onSelected: index => dispatch(changeStyle(index))
|
||||
onSelected: index => {
|
||||
dispatch(changeStyle(index))
|
||||
}
|
||||
})
|
||||
|
||||
const StyleListViewer = () => {
|
||||
|
|
|
@ -9,7 +9,6 @@ const initialState = {
|
|||
}
|
||||
|
||||
export default function appReducer(state = initialState, action) {
|
||||
console.log(state)
|
||||
switch (action.type) {
|
||||
case actionTypes.GENERATE_QR_INFO: {
|
||||
return Object.assign({}, state, {
|
||||
|
|
Loading…
Reference in New Issue