D
D
Denis Sokolov2020-11-21 21:26:44
JavaScript
Denis Sokolov, 2020-11-21 21:26:44

Why doesn't React props work?

When I put active and setActive in front, props don't work, and when I put active and setActive in the back, they don't work, but props works

export const CardNews = ({ active, setActive }, props) => {

    return (
        <div className="news-card">
            <div className="news-card__content">
                <div className="news-card__img">
                    <img src={image_1} alt="img" className="news-card__image" />
                </div>
                <div className="news-card__text">
                    <div className="news-card__title">{props.title}</div>
                    <div className="news-card__descr">{props.descr}</div>
                    <button className="check-news" id={props.id} onClick={() => setActive(true)}>
                        Читать
                    </button>
                </div>
            </div>
        </div>
    )
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
abberati, 2020-11-21
@Denis147258369

({ active, setActive, ... props })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question