Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. function mapStateToProps(state){
  2.  
  3. import React, {Component} from 'react';
  4. import Thermometer from "react-thermometer";
  5. import {bindActionCreators} from 'redux';
  6. import {connect} from 'react-redux';
  7. import {incrementValue} from '../actions/index';
  8.  
  9. class Thermo extends Component{
  10. getValue(){
  11. return this.props.val;
  12. }
  13.  
  14. render(){
  15. return(
  16. <div>
  17. <Thermometer
  18. min={0}
  19. max={90}
  20. width={10}
  21. height={90}
  22. backgroundColor={'gray'}
  23. fillColor={'pink'}
  24. current={this.getValue()}
  25. />
  26. <Button onClick={() => this.props.incrementValue(val)}>+</Button>
  27. </div>
  28. )
  29. }
  30.  
  31. function mapStateToProps(state){
  32. return{
  33. val: state.val
  34. };
  35. }
  36.  
  37. function matchDispatchToProps(dispatch){
  38. return bindActionCreators({incrementValue: incrementValue}, dispatch);
  39. }
  40. }
  41.  
  42. export default connect(mapStateToProps, matchDispatchToProps)(Thermo);
  43.  
  44. var path = require('path');
  45. var webpack = require('webpack');
  46.  
  47. module.exports = {
  48. devServer: {
  49. inline: true,
  50. contentBase: './src',
  51. port: 3000
  52. },
  53. devtool: 'cheap-module-eval-source-map',
  54. entry: './dev/js/index.js',
  55. module: {
  56. loaders: [
  57. {
  58. test: /.js$/,
  59. loaders: ['babel'],
  60. exclude: /node_modules/
  61. },
  62. {
  63. test: /.scss/,
  64. loader: 'style-loader!css-loader!sass-loader'
  65. }
  66. ]
  67. },
  68. output: {
  69. path: 'src',
  70. filename: 'js/bundle.min.js'
  71. },
  72. plugins: [
  73. new webpack.optimize.OccurrenceOrderPlugin()
  74. ]
  75. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement