F
F
Famouss2020-09-03 07:23:15
React
Famouss, 2020-09-03 07:23:15

Why can't the className be set directly to the component?

The next question is why, in order to set the style for a component, you need to wrap it in a block and already set a class for this block?

let myFunc() {
     return(
         <div className={styles.item}>
           <NavLink to='#' path='/'>Link</NavLink>
        </div>
     )
}

Wrapping the link in a block, it seems to me, is not very appropriate.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
inzeppelin, 2020-09-03
@inzeppelin

Why can't it? Can be same as props. Here is the NavLink implementation in React-router: https://github.com/ReactTraining/react-router/blob...
And in the example below

<NavLink className="test" activeClassName="a" exact to="/">I have class</NavLink>


Everything is working

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question