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.

Provide an API to exclude or overload AppThemeProvider

See original GitHub issue

Context

On the HP DevEx project, we’re using the default Backstage frontend app for the admin interface. The frontend that users see is a different React app in the same monorepo. Each major section of the UI is a separate package that uses the Backstage plugin template. We use @backstage/cli plugin:serve to run each section separately while doing development. We use the dev.tsx file to configure the development environment for each section. Here is what the bootstrap mechanism looks like,

import React from 'react';
import ReactDOM from 'react-dom';
import { createApp } from '@backstage/core-app-api';
import { Section } from '../src';

const app = createApp();
const BackstageProvider = app.getProvider();

const HpDevExApp = ({ children }) => {
   const wrap  = () => {
     // our setup goes here which uses config from app-config.yaml
   }; 
   return wrap(children);
}

const DevApp: FC<{
  children: ReactNode;
}> = ({ children }: { children: ReactNode }) => {
  return (
    <Suspense fallback={<p>Loading...</p>}>
      <BackstageProvider>
        <HpDevExApp>{children}</HpDevExApp>
      </BackstageProvider>
    </Suspense>
  );
};


ReactDOM.render(
  <DevApp>
    <Section />
  </DevApp>,
  document.getElementById('root'),
);

The benefit of this setup is that we’re able to use all of the Backstage APIs but use HP’s internal component framework. The problem is that <CssBaseline /> messes with CSS from HP’s component framework. I would really like to eliminate AppThemeProvider or replace it with another provider.

Currently, we created a patch to remove CSS provided by <CssBaseline /> but it messes with the CSS of our Backstage admin site because that site actually needs those styles.

Feature Suggestion

Make it possible to replace or remove AppThemeProvider from the context tree.

Possible Implementation

The possible API could be something like this,

const app = createApp();
const BackstageProvider = app.getProvider({ AppThemeProvider: ({ children }) =>  children });

We can contribute the change if Backstage team can suggest an API.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
tarascommented, Sep 10, 2021

@Rugvip perfect! We’ll work with this.

@minkimcello let’s work on this together when you get a chance.

0reactions
tarascommented, Sep 16, 2021

Closed in #7201

Read more comments on GitHub >

github_iconTop Results From Across the Web

API Reference - styled-components
Any valid React component that can handle a theme prop. Returns the passed component inside a wrapper (higher order component).
Read more >
reactjs - Theme state changes will be rerendered just once in ...
I am a beginner in ReactJs and I want to change the theme just by clicking a button. But this just works for...
Read more >
@material-ui/styles | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
GlobalSuppressions.cs - Reference Source - Microsoft
Project path: ndp\fx\src\xsp\system\Web\System.Web.csproj. Files: 1,740. Lines of code: 417,257. Bytes: 18,092,848. Declared symbols: 32,824
Read more >
material-ui/core/CHANGELOG.md - UNPKG
38, - [core] Allow React 17 in peer dependencies (#23697) @ ... 272, - [docs] List all the Tab components under the API...
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