-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Connect the <PreviewFrame /> Component #1628
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
Conversation
Hi, |
const mapStateToProps = state => ({ | ||
files: state.files, | ||
htmlFile: getHTMLFile(state.files), | ||
...state.ide, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that the other components that have recently been updated to use react-redux
aren't like this, but I think it would be better to pull out the specific parts of the redux state that this component depends on. This is because the component will re-render if any of these change, versus the specific parts of the redux state that the component actually depends on.
The other components that are like this should be fixed too, but that's a matter for another PR 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I see, that seemed odd anyway. Ok, ill get on it.
@ZenVeg thanks for submitting this PR! Glad to have you as a contributor. It's totally okay to not do the whole code contribution process perfectly! If there's something to fix, I (or other maintainers) will tell you what to do. |
Sweet, thanks. Happy to be able to give sth back to p5. Nevertheless, I can't resist asking. Would it be too much to ask to put a hacktoberfest label on that Issue? |
@@ -350,4 +363,30 @@ PreviewFrame.defaultProps = { | |||
cmController: {} | |||
}; | |||
|
|||
export default PreviewFrame; | |||
const mapStateToProps = state => ({ | |||
files: state.files, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're missing a bunch of props here. The ones that were passed via IDEView are:
htmlFile={this.props.htmlFile}
files={this.props.files}
content={this.props.selectedFile.content}
isPlaying={this.props.ide.isPlaying}
isAccessibleOutputPlaying={
this.props.ide.isAccessibleOutputPlaying
}
textOutput={this.props.preferences.textOutput}
gridOutput={this.props.preferences.gridOutput}
soundOutput={this.props.preferences.soundOutput}
setTextOutput={this.props.setTextOutput}
setGridOutput={this.props.setGridOutput}
setSoundOutput={this.props.setSoundOutput}
dispatchConsoleEvent={this.props.dispatchConsoleEvent}
autorefresh={this.props.preferences.autorefresh}
previewIsRefreshing={this.props.ide.previewIsRefreshing}
endSketchRefresh={this.props.endSketchRefresh}
stopSketch={this.props.stopSketch}
setBlobUrl={this.props.setBlobUrl}
expandConsole={this.props.expandConsole}
clearConsole={this.props.clearConsole}
cmController={this.cmController}
language={this.props.preferences.language}
I... don't know what hacktoberfest is. |
I'm not insecure about the content prop. is that correct? and are those all? do the rest come from the dispatches? hacktoberfest is one of these events supposed to motivate people to contribute to open source and giving guidelines to achieve this. if u give this PR the label "hacktoberfest" it gets accepted and I can win a shirt or get a tree planted. that's all. that label shall prevent nonsense PRs: |
If the prop was passed in import { stopSketch } from '../actions/ide';
// ...
const mapDispatchToProps = dispatch => bindActionCreators(
{
stopSketch,
// the other actions...
},
dispatch
); |
Ok, I imported all dispatches individually so the only prop i didn't find was cmController which I again passed via IDEView. that right? |
|
||
|
||
const mapDispatchToProps = dispatch => bindActionCreators( | ||
Object.assign( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't right, as these functions aren't getting passed to the PreviewFrame
component and the app crashes when you click play. You shouldn't need to use Object.assign
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I transformed mapDispatchToProps to an object. the tests pass and the editor seems to run now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
working for me now! thank you ✨
[#1590] Turning
<PreviewFrame/>
into a containerI added mapStateToProps() and mapDispatchToProps() to
<PreviewFrame/>
.<PreviewFrame/>
does not receive any props from<IDEView />
anymore.I added connect() to the export.
Linting and npm test don't throw errors.