Skip to content

React Performance question #164

Answered by dcastil
jdolinski1 asked this question in Help
Discussion options

You must be logged in to vote

Hey @jdolinski1! 👋

TLDR: Yes, you can call twMerge during render of many components without expecting performance issues. I built tailwind-merge exactly for this use case. But you should only call it when you actually need it because extreme usage might cause issues.

Long version here 👇

I build tailwind-merge so you can use it like this within React components:

function MyInput({ className, someBool, someOtherBool, ...props }) {
    return (
        <input
            {...props}
            className={twMerge(
                '…',
                someBool && '…',
                someOtherBool ? '…' : '…',
                someGlobalBool && '…',
                className,
            )}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jdolinski1
Comment options

Answer selected by jdolinski1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
context-v1 Related to tailwind-merge v1
2 participants