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.

Code example for CX and Custom Components documentation isn't functional

See original GitHub issue

The example provided in the documentation for how to use the CX function with Custom Components (here) does not appear to be working properly both on the site and on the sandbox.

CodeSandbox claims that there is a missing reference to Emotion, but even after adding it, the custom component is still missing all styling.

Investigating further, it appears that the option DOM class attribute is rendering as the string value of [object Object].

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Rall3ncommented, Jun 22, 2020

@ebonow Following should be all the changes needed to make the example work again:

/** @jsx jsx */
// import React from 'react';
import { jsx } from '@emotion/core';

/* ... */

  return (
    <div
      ref={innerRef}
      css={getStyles('option', props)}
      className={cx(
        {
          option: true,
          'option--is-disabled': isDisabled,
          'option--is-focused': isFocused,
          'option--is-selected': isSelected,
        },
        className
      )}
      {...innerProps}
    >
      {children}
    </div>
  );
};

The jsx import from @emotion/core replaces the React import that is needed on every React file. This also includes the functionality of the css prop. The comment on the top tells the compiler to use jsx instead of React.

1reaction
bladeycommented, Jul 6, 2020

Thanks for working this out @Rall3n and @ebonow, I’ve created a PR with the necessary changes.

Could you please have a look at PR https://github.com/JedWatson/react-select/pull/4112 and give me the go ahead to release it.

Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Customizing CMS Components - Spartacus Documentation
The mapping is provided in a configuration that can be customized. This allows you to configure a custom component to render a specific...
Read more >
React's new killer documentation focused only on functional ...
React's new killer documentation focused only on functional components. It's no secret that the old React documentation is useless most of ...
Read more >
Configure a Component for Experience Builder
Configure a Component for Experience Builder. Make a custom Lightning web component available in Experience Builder, where users can add it to the...
Read more >
Developing Open Storefront Framework Applications for ...
If the JSON document does not include operationId values, use the zero-based index of the ordering of the REST endpoints in the document....
Read more >
Writing Custom Components | Prismatic Docs
Sample component code is referenced throughout this page. ... which is an async function with two parameters that may or may not have...
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