Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React < 16.3 support (WIP) #1113

Closed
wants to merge 2 commits into from
Closed

React < 16.3 support (WIP) #1113

wants to merge 2 commits into from

Conversation

rafaesc
Copy link
Collaborator

@rafaesc rafaesc commented Aug 29, 2018

Issue #1094

Copy link
Member

@sapegin sapegin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This is super cool! ❤️

One sad note: could you please make a PR from the next branch? And I'd probably wait until the Enzyme issue is resolved, we can't merge it with broken tests. In the worst case, I'll change peer deps in 8.0.0 and we'll merge this is a path release later. 🙏

@@ -159,7 +158,7 @@
"test:browser:customised": "node test/browser.js examples/customised/styleguide/index.html",
"test:browser:sections": "node test/browser.js examples/sections/styleguide/index.html",
"precommit": "lint-staged",
"format": "prettier --write '**/*.{js,md}'",
"format": "prettier --write \"**/*.{js,md}\"",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I had problems in Windows, it relates with this issue:
prettier/prettier#4086 (comment)

And here explains that
https://prettier.io/docs/en/cli.html

Don't forget the quotes around the globs! The quotes make sure that Prettier expands the globs rather than your shell, for cross-platform usage.

Maybe it should be other PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️

We should change it here, otherwise the script will overwrite the command eventually:
https://github.com/sapegin/mrm-tasks/blob/master/packages/mrm-task-prettier/index.js#L82

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing project @sapegin!


Provider.propTypes = {
children: PropTypes.any,
codeRevision: PropTypes.number.isRequired,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not using some of these props.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have copied from this childContextTypes
https://github.com/styleguidist/react-styleguidist/blob/master/src/rsg-components/StyleGuide/StyleGuide.js#L45-L50

because they are used in several components


export const Context = React.createContext();

export function Consumer(WrappedComponent) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd call it ConfigConsumer to make more clear what it does.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!

@@ -0,0 +1,39 @@
import React, { Component } from 'react';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move it to rsg-components like any other component, and rename to ConfigProvider.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!


export function Provider(props) {
const { children, ...rest } = props;
const ui = typeof children === 'function' ? children(this.state) : children;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need both here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be removed!

const Styled = styledWrapper(styles, WrappedComponent, componentName);

return class extends Component {
static displayName = `Consumer(${componentName})`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably shouldn't show the same name as for context consumer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it was created to give a name, I wanted to make something similar like Styled(Component), but yes, I will remove it


return class extends Component {
static displayName = `Consumer(${componentName})`;
state = {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you don't need state here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will change it

@@ -1,26 +1,22 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import createStyleSheet from '../../styles/createStyleSheet';
import { Context } from '../../provider';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be Consumer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't use it, because Consumer gives to component all context as props (codeRevision, config, slots and displayMode), and Styled only needs the object config.

When I use Consumer, in Styled appears an error, because all context's properties are used here
https://github.com/styleguidist/react-styleguidist/blob/master/src/rsg-components/Styled/Styled.js#L15

So for that reason, I created a custom Consumer that gives only config property

@sapegin sapegin added this to the 8.0.0: New editor milestone Aug 30, 2018
@rafaesc
Copy link
Collaborator Author

rafaesc commented Aug 31, 2018

No problem, I will create another PR taking next as branch. I hope that Enzyme could fix soon.

@rafaesc rafaesc closed this Aug 31, 2018
@sapegin sapegin deleted the feat-react-update branch November 11, 2020 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants