Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

React Context happy fun times #1437

@smashwilson

Description

@smashwilson

So we pass a lot of props around.

<GitTabView
ref={c => { this.refView = c; }}
isLoading={repoData.fetchInProgress}
repository={this.props.repository}
lastCommit={repoData.lastCommit}
recentCommits={repoData.recentCommits}
isMerging={repoData.isMerging}
isRebasing={repoData.isRebasing}
hasUndoHistory={repoData.hasUndoHistory}
currentBranch={repoData.currentBranch}
unstagedChanges={repoData.unstagedChanges}
stagedChanges={repoData.stagedChanges}
mergeConflicts={repoData.mergeConflicts}
workingDirectoryPath={repoData.workingDirectoryPath}
mergeMessage={repoData.mergeMessage}
mentionableUsers={this.state.mentionableUsers}
selectedCoAuthors={this.state.selectedCoAuthors}
updateSelectedCoAuthors={this.updateSelectedCoAuthors}
resolutionProgress={this.props.resolutionProgress}
workspace={this.props.workspace}
commandRegistry={this.props.commandRegistry}
grammars={this.props.grammars}
tooltips={this.props.tooltips}
notificationManager={this.props.notificationManager}
project={this.props.project}
confirm={this.props.confirm}
config={this.props.config}
initializeRepo={this.props.initializeRepo}
openFiles={this.props.openFiles}
discardWorkDirChangesForPaths={this.props.discardWorkDirChangesForPaths}
undoLastDiscard={this.props.undoLastDiscard}
stageFilePatch={this.stageFilePatch}
unstageFilePatch={this.unstageFilePatch}
attemptFileStageOperation={this.attemptFileStageOperation}
attemptStageAllOperation={this.attemptStageAllOperation}
prepareToCommit={this.prepareToCommit}
commit={this.commit}
undoLastCommit={this.undoLastCommit}
push={this.push}
pull={this.pull}
fetch={this.fetch}
checkout={this.checkout}
abortMerge={this.abortMerge}
resolveAsOurs={this.resolveAsOurs}
resolveAsTheirs={this.resolveAsTheirs}
/>

React 16.3 introduced a fancy new Context API which doesn't even carry the "please don't use this" scare language that the old one had. We can likely take advantage of this to make our prop situation much more manageable, especially for accessing:

  • Atom environment properties
  • Synchronously available Repository data
  • Bound action methods

This isn't a trivial implementation, though. There are a lot of weird edge cases in the ways we handle event subscriptions, re-rendering timing, and so on that make this tricky to implement in a way that's a clear improvement. We would also have to be careful not to just re-implement Redux poorly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions