K
K
kirillleogky2020-06-06 12:31:04
React
kirillleogky, 2020-06-06 12:31:04

How to call the component's redux functionality?

There is a code:
addTodo.js

import PropTypes from "prop-types";
import { connect } from "react-redux";
import actions from "../../actions";

function addTodo (props) {
  window.console.log('hey');
}

addTodo.propTypes = {
  firstData: PropTypes.string,
  secondData: PropTypes.object,
  thirdData: PropTypes.array,
  setFirstData: PropTypes.func,
};

const mapStateToProps = (store) => {
  return {
    firstData: store.firstData.data,
    secondData: store.secondData.data,
    thirdData: store.thirdData.data,
  };
};

const mapDispatchToProps = (dispatch) => {
  return {
    setFirstData: (data) => dispatch(actions.setFirstData(data)),
  };
};

export default connect(mapStateToProps, mapDispatchToProps)(addTodo);


I need to call its functionality in another file (output console.log first)
import React from "react"
import PropTypes from "prop-types";
import { connect } from "react-redux";
import actions from "../../actions";
import addTodo from "./addTodo"

function addTodoInputBtn(props) {
  return (
    <form onSubmit={ КАК ПРАВИЛЬНО ЗАПИСАТЬ ВЫЗОВ ЗДЕСЬ } className="todo_block-add_todo add_todo_block">
......................


How to call addTodo if I'm going to use redux in the future?
After all, in this case it is an object / component and not a function
There is an option addTodo.WrappedComponent () but I'm sure that this is not a very good option

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question