Example of using `withTheme` with Flow

Open
#53 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, react
Domain
documentation

Research direction

Start from the withTheme and PureComponent examples in the issue and investigate how the wrapped component's Flow props are expected to be declared. Document an idiomatic Flow example that prevents theme from being required at JSX call sites; no file or test is identified in the issue.

Written by the indexing model from the issue text.

Description

question

I create a component with Props type that includes a theme:

type Props = {
  theme: MyTheme,
  otherProps: any,
};

class MyCmp extends PureComponent<Props> { ... }

Then I export it like this:

export withTheme(MyCmp);

Then when I import it and use in JSX I'm getting a Flow error that theme prop is required.

What is the idiomatic example of defining withTheme component with Flow?

Dominant language
JavaScript
Stars
466
Forks
53
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from callstack/react-theme-provider

All issues in callstack/react-theme-provider

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.