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

Setup file with a project that already uses react-with-styles #875

Copy link
Copy link
Open
@mmahalwy

Description

@mmahalwy
Issue body actions

Hello there!

Wanted to share an example setup file for projects that currently use react-with-styles as this would result to error:
image

Example setup.js:

import globalCache from 'global-cache';
import ThemedStyleSheet from 'react-with-styles/lib/ThemedStyleSheet';
import aphroditeInterface from 'react-with-styles-interface-aphrodite';
import ReactDatesDefaultTheme from 'react-dates/lib/theme/DefaultTheme';

import YourCurrentTheme from './path/to/your/current/theme';

globalCache.setIfMissingThenGet('withStyles', () => {
  /*
   * Registering the default theme more than once clobbers all of the
   * previously created styles, which causes errors to happen. This can happen
   * if this file appears in more than one bundle on the same page. To avoid
   * this, we are using a global cache.
   */
  ThemedStyleSheet.registerTheme({
    ...YourCurrentTheme,
    ...ReactDatesDefaultTheme,
  });

  ThemedStyleSheet.registerInterface(aphroditeInterface);

  return ThemedStyleSheet;
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationInstructions and explanations for stuff!Instructions and explanations for stuff!

    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.