-
Notifications
You must be signed in to change notification settings - Fork 0
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
SARS-CoV-2 verison of RAMPART #1
base: master
Are you sure you want to change the base?
Changes from 1 commit
45640ed
68145fa
74c38ff
169e17a
6d2c7b9
6783cf4
3867c67
f70b095
4465258
acdab22
1bfdd05
2b37599
681249e
8e4b169
ba32447
412c26b
199ca87
bba5d22
e955c8a
119a3ce
981fd70
1d03b3b
cebd4ea
4cba686
9ad8c7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,33 +8,22 @@ class MutationsTree extends React.Component { | |
this.state = {}; | ||
} | ||
|
||
createVariants(variants, level){ | ||
return variants.flatMap((variant) => [ | ||
createVariants = (variants, level) => { | ||
return (variants.flatMap((variant) => [ | ||
`${'---'.repeat(level)}variant: ${variant.name} (${variant.mutations.map(mutation=>mutation.from+mutation.position+mutation.to).join(", ")})`, | ||
...this.createVariants(variant.subs, level+1) | ||
]) | ||
} | ||
|
||
|
||
componentDidMount() { | ||
let variantsTree = this.createVariants(this.props.data, 0).map(i => { | ||
])).map(i => { | ||
return <p>{i}</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't react complaining that array elements don't have any There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it doesn't, as far as I can see There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure? Doesn't it output warnings to the console in the runtime? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, I see only the log outputs which were there in original rampart too. |
||
}); | ||
this.setState({data:variantsTree}); | ||
} | ||
|
||
componentDidUpdate(prevProps) { | ||
this.render(); | ||
} | ||
|
||
|
||
|
||
render() { | ||
return ( | ||
<Container width="90%" ref=""> | ||
<Title> | ||
{"Mutations tree"} | ||
</Title> | ||
{this.state.data} | ||
{this.createVariants(this.props.data, 0)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about this? isn't it the simplest way how to achieve what we want, without using hooks, etc? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, assuming this is performant enough (I have no idea whether the caching in previous version was because of performance or not). Anyway, this looks good, let's just rename it to renderVariants |
||
{this.props.renderProp ? this.props.renderProp : null} | ||
</Container> | ||
) | ||
|
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.
Is this correct? createVariants is recursive, and this therefore
<p>
escapes recursively. Is that what we want?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, you are right, this might be a problem. maybe if we seperated the second map to the second function, it might by okay.