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.

Create a `withTheme` higher-order component

See original GitHub issue

Ideally, we should have a withTheme HOC in which fields, widgets, and/or templates can be passed – this can be used to implement custom themes.

This was implemented in #1013, but that included several other breaking changes – so I’d like to see a PR which just implements the withTheme component so it can be added to the library.

Example usage:

import withTheme from 'react-jsonschema-form/lib/components/withTheme';

import widgets from './my-theme/widgets';
import templates from './my-theme/templates';

const Form = withTheme('MyTheme', { widgets, templates });

I’m listing the popular / currently maintained libraries that fork off of react-jsonschema-form and implement a UI framework other than bootstrap 3, so that the maintainers of those repos are aware of the progress on this issue – or if anyone wants to jump in and do this, that would be great! @peterkelly @cwhatley @vip-git @selfkeyfoundation @eddyzhang1986 @twoabove @nilportugues

BS4 https://github.com/peterkelly/react-jsonschema-form-bs4 Material https://github.com/cwhatley/material-ui-react-jsonschema-form https://github.com/vip-git/react-jsonschema-form-material-ui https://github.com/SelfKeyFoundation/react-jsonschema-form-material-theme https://github.com/TwoAbove/jsonschema-form-for-material-ui Antd https://github.com/eddyzhang1986/antd-jsonschema-form Semantic UI https://github.com/nilportugues/react-jsonschema-form-semanticui

See #899

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:34
  • Comments:28 (15 by maintainers)

github_iconTop GitHub Comments

7reactions
TwoAbovecommented, May 26, 2019

@epicfaace I think that a schema like this is a good one:

import { withTheme } from "react-jsonschema-form/core";
import MUITheme from "react-jsonschema-form/themes/material-ui";

const Form = withTheme(MUITheme);

This way, thanks to tree shaking, in prod only the used theme remains, and you can keep all of them in one place + keep them easily updatable.

(also keeps good compatibility with typescript, but that’s another thing 😉 )

6reactions
agustin107commented, Jul 9, 2019

@themakerman I’ve created rjsf-material-ui, which allows you to use material-ui v4.2 with react-jsonschema-form. Check it out here: https://github.com/cybertec-postgresql/rjsf-material-ui Playground: https://cybertec-postgresql.github.io/rjsf-material-ui/ Feedback is welcome!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Higher-Order Components - React
A higher-order component (HOC) is an advanced technique in React for reusing component logic. HOCs are not part of the React API, per...
Read more >
withTheme() higher order component of styled ... - GitHub
withTheme () higher order component of styled-component isn't working. Is something possible to fix this ? You can take a look at this...
Read more >
What Are Higher-Order Components in React?
Higher -order components are one of React's most popular design patterns, allowing you to define reusable stateful logic and create powerful, ...
Read more >
Introduction to Higher-Order Components in React by example
In this blog, we will learn about High-Order Components and how we use them in React. It also covers coding and debugging Higher-order...
Read more >
Full HOC Example | React TypeScript Cheatsheets
This is an HOC example for you to copy and paste. If certain pieces don't make sense for you, head to the React...
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