question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question about syntax

See original GitHub issue

Hi, Yesterday I took your package to replace withStyles from material-ui for yours. I have a question about construction <div ...css(styles.classname1, styles.classname2)/> As for me that syntax is slightly redundant and also with that I can’t use “classname” package, as example: { classnames(css(styles.classname1)), {classnames(css(styles.classname2)): this.state.error } }, or simply add some static styles, as example: <div className="error", {...css(styles.classname)}> or <div className={classname({ classnames(css(styles.classname1)), {error: this.state.error})}.

It’s only two cases that I’ve run into in a few days. I’ve wrapped some methods and now it works as always, as example: <div className={classnames(styles.firstLink, styles.secondLink, {error: true})}> That’s work with JSS and Aphrodite.

Methods that I wrap:

const cssWrapper = (...params) => css.apply(css, params).className;
const aphroditeInterfaceCustom = {
    ...aphroditeInterface,
    create (styleHash) {
        const styles = aphroditeInterface.create(styleHash);

        return each(styles, (value, key) => {
            styles[key] = cssWrapper(value);
        });
    }
};

So, maybe I don’t know or missed something, please explain for me why you chose this approach.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

3reactions
Nazerbayevcommented, Jul 24, 2018

So, if I want to make a shareable component and I want it to be flexible allowing the other party to add their own classnames in the inner pieces of my code then the solution is to make the other party add an additional dependency to their project (and learn how to use it) instead of using the usual pattern of a simple prop?

I apologize if im not understanding something basic, but it seems to me that it goes totally agaisnt the main premise of this library, citing from the very first line of the readme: components without being tightly coupled to one implementation.

Edit: I want to clarify something, i’m not complaining for the sake of complaining, my case is that i’m reading through the source code of react-dates looking for a way to override some style choices that it has, probably making a fork if i have to, and I stumbled upon this library.

2reactions
Nazerbayevcommented, Jul 24, 2018

I do agree with The idea is that you don't use class names or inline styles at all, the problem is for example if you are developing a component that will be used as a dependency on other projects. Ideally the component should be flexible enough to allow the users to override your styles, and the easiest way to do that is having one or more props with custom static classnames defined by the user, not the component developer.

Edit: I dont know if adding external static classnames via props is currently possible, at least it is not clear enough how to do that on the current documentation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Syntax Questions and Answers - Study.com
Access the answers to hundreds of Syntax questions that are explained in a way that's easy for you to understand. Can't find the...
Read more >
258 questions with answers in SYNTAX | Science topic
Is it possible to test syntactic understanding without requiring semantic knowledge? Question. 46 answers. Dec 17, 2014.
Read more >
LX522 Syntax I: Questions and Answers
Yes. Generally, when we're talking about syntax, we're talking about spoken language rather than written language (despite the fact that we write out...
Read more >
Newest 'syntax' Questions - Linguistics Stack Exchange
Questions tagged [syntax] · tree diagrams, X-Bar theory · Conditional followed by imperative · Can clauses with transitive verbs that stand for experiences...
Read more >
13 Important Questions About Syntax | Chapter 8 - YouTube
Q1. What is the “all and only” criterion? Q2. Do phrase structure rules represent deep structure or surface structure?Q3.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found