Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
*.log
lib
coverage
.idea
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-gateway",
"version": "3.0.0",
"version": "3.0.1",
"description": "Render React DOM into a new context",
"main": "lib/index.js",
"scripts": {
Expand Down
8 changes: 7 additions & 1 deletion src/GatewayRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ export default class GatewayRegistry {
this._currentId = 0;
}

_getChildIndex(childId) {
return +childId.match(/\d+$/)[0]
}

_renderContainer(name) {
if (!this._containers[name] || !this._children[name]) {
return;
}

this._containers[name].setState({
children: Object.keys(this._children[name]).sort().map(id => this._children[name][id])
children: Object.keys(this._children[name])
.sort((a, b) => this._getChildIndex(a) - this._getChildIndex(b))
.map(id => this._children[name][id])
Copy link

@richardscarrott richardscarrott Jul 6, 2022

Choose a reason for hiding this comment

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

@kseniya57 do you know if the name even needs to be part of the key; i.e. any reason ln 47 can't just be:

const gatewayId = this._currentId;

That way this could avoid the regex and instead cast it to a number?

});
}

Expand Down