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

Split new CodeEvaluator component out from Preview #976

Merged
merged 8 commits into from
May 14, 2018

Conversation

kidkuro
Copy link
Contributor

@kidkuro kidkuro commented May 9, 2018

Fixes #975

Created new CodeEvaluator component, by extracting it from Preview. This separates the concerns/responsibilities and also exposes the CodeEvaluator for use in plugins.

@codecov-io
Copy link

codecov-io commented May 10, 2018

Codecov Report

Merging #976 into master will increase coverage by 0.38%.
The diff coverage is 100%.

Impacted Files Coverage Δ
src/rsg-components/ReactExample/ReactExample.js 100% <100%> (ø)
src/rsg-components/Preview/Preview.js 100% <100%> (+10.34%) ⬆️

@kidkuro
Copy link
Contributor Author

kidkuro commented May 10, 2018

Hmm... I increased coverage over original code. I'm guessing your coverage standards have increased. I'll have a go of adding more tests.


state = this.props.initialState;
setStateBinded = this.setState.bind(this);
/* eslint-disable no-invalid-this */
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 still need this?

Copy link
Contributor Author

@kidkuro kidkuro May 11, 2018

Choose a reason for hiding this comment

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

Yes, in the handleError function.

code={code}
evalInContext={this.props.evalInContext}
onError={this.handleError}
compilerConfig={this.context.config.compilerConfig}
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 CodeEvaluator read config from context itself, similar to what you did for the Editor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it inherits context when it is rendered via ReactDOM.render(wrappedComponent, this.mountNode);

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, true.

@@ -0,0 +1,94 @@
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.

Do you have any new code here? If not I won't read the whole file ;-)

This is React specific, so we should reflect it in the name: something like ReactExample (not the best too but I have no better ideas ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, right... yeah, git isn't being your friend here, this is all moved from Preview.

The only things I changed were:

  • I renamed PreviewComponent to InitialStateComponent
  • I passed in compilerConfig as a prop instead of reading it off context as discussed above.

I'm happy to rename it... I struggled to come up with a decent name to.


// Wrap everything in a React component to leverage the state management
// of this component
class InitialStateComponent extends Component {
Copy link
Member

Choose a reason for hiding this comment

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

Something like StateHolder would be more correct: it's not just initial state here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha, I'll change it.

code={code}
evalInContext={this.props.evalInContext}
onError={this.handleError}
compilerConfig={this.context.config.compilerConfig}
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, true.

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.

Just one more suggestion ;-)

@kidkuro
Copy link
Contributor Author

kidkuro commented May 13, 2018

Oops! Sorry, used to a precommit hook that runs tests. Will fix this now.

@sapegin sapegin merged commit 7f5137e into styleguidist:master May 14, 2018
@sapegin
Copy link
Member

sapegin commented May 14, 2018

Thanks, merged!

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.

3 participants