Skip to content

Conditional style is overwritten in loop when using cssNamespace #70

@tillkolter

Description

@tillkolter

Hi,
I have a namespace #my-widget.

Components looks schematically like this

const PolarityCell = styled.td`
   color: ${({isNegative}) => isNegative ? 'red': 'green'};
`

<div id="my-widget">
    <table>
        {entries.map(({value, isNegative}) => (
            <tr>
                <td><PolarityCell isNegative={isNegative}>{value}</PolarityCell></td>
            </tr>
         )}
    </table>
</div>
}

When entries: [{value: '1', isNegative: false}, {value: '-2', isNegative: true}] all values are red

When entries: [{value: '-1', isNegative: true}, {value: '2', isNegative: false}] all values are green

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