Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

how to style child Component when child and parent both use css.module? #408

Copy link
Copy link

Description

@wine-fall
Issue body actions

parent.tsx

import React from 'react';
import {Child} from './Child';
import styles from './index.module.less';

const Parent: React.FC = () => {
    return (
            <Child className={styles.child}></Child>
    );
};

export default Parent;

child.tsx

import React from 'react';
import styles from './child.module.less';
interface ChildProps {
    className?: string;
}

export const Child: React.FC<ChildProps> = (props) => {
    return (
        <div className={props.className}>
            <span className={styles.childP}>123</span>
        </div>
    );
};

child.module.less

.childP {
    color: black;
}

and in index.module.less which imported in parent.tsx file

.child {
    :global {
        .childP{
            color: red;
        }
    }
}

It doesn't work??? why ??? and what should I do?

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.