F
F
Flopipi2020-05-29 19:03:03
React
Flopipi, 2020-05-29 19:03:03

How to call a method?

Is there any way to call the function at the place where I tried to call it, so that the text that the method will return is displayed there?

class RangeTimeEvent extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            card: []
        }
        this.takeDate = this.takeDate.bind(this);
    }

    takeDate() {
        this.state.card.map(index => {
            return (
                <div>{index.date}</div>
            );
        })
    }

    render() {
            return (
                <div className="in-time">
                    <div className="time block active tab-1"><p>{this.takeDate()}</p></div>
                </div>
            )
        }
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2020-05-29
@Flopipi

takeDate() {
        return this.state.card.map(index => {
            return (
                <div>{index.date}</div>
            );
        })
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question