Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. //action file
  2. import {
  3. OPEN_CHORDS_MODAL,
  4. CLOSE_CHORDS_MODAL
  5. } from './types';
  6.  
  7. //exporting the action, if open payload will be true : false
  8. export const openChordsModal = () => {
  9. console.log('Chords Modal Button Clicked')
  10. return {
  11. type: OPEN_CHORDS_MODAL,
  12. payload: true
  13. };
  14. };
  15.  
  16. //exporting the action, if open payload will be true : false
  17. export const closeChordsModal = () => ({
  18. type: CLOSE_CHORDS_MODAL,
  19. payload: false
  20. });
  21.  
  22.  
  23.  
  24.  
  25. //type file in action
  26. export const OPEN_CHORDS_MODAL = 'open_chords_modal';
  27. export const CLOSE_CHORDS_MODAL = 'close_chords_modal';
  28.  
  29. //index file in actions folder
  30. export * from './modal_actions';
  31.  
  32.  
  33. //component file
  34. import React, { Component } from 'react';
  35. import { View } from 'react-native';
  36. import { Button } from 'react-native-elements';
  37. import { connect } from 'react-redux';
  38. import { openChordsModal } from '../actions';
  39.  
  40. //we are importing connect because we are using an action to handle openChordModals
  41.  
  42. class ViewChordsButton extends Component {
  43. render() {
  44. return (
  45. <View style={this.props.style}>
  46. <Button
  47. raised
  48. icon={{ name: 'library-music'}}
  49. title="View Transposed Chords"
  50. backgroundColor="#2196F3"
  51. onPress={() => this.props.openChordsModal}
  52. />
  53. </View>
  54. );
  55. }
  56. }
  57.  
  58. //were not gonna pass any state to props so no mapToStateProps, but we have to pass openChordsModal
  59. export default connect(null, { openChordsModal })(ViewChordsButton);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement