Skip to content

Commit

Permalink
feat: If componentn is empty, html is returned empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetkuslular committed Jul 19, 2023
1 parent 079b253 commit 81ef52f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "voltranjs",
"version": "1.2.0-beta.7",
"version": "1.2.0-beta.8",
"main": "src/index.js",
"author": "Hepsiburada Technology Team",
"bin": {
Expand Down
1 change: 0 additions & 1 deletion src/renderMultiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ async function setInitialStates(renderers) {
const winner = getWinner(requests, hashes);
incWinnerScore(winner, hashes);
putWinnerMap(serviceName, renderer.winnerMap, winner);

if (!promises[winner.hash]) {
promises[winner.hash] = callback => {
winner
Expand Down
4 changes: 1 addition & 3 deletions src/universal/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ class App extends PureComponent {
const { isHydratingCompleted } = this.state;
return (
<ReactRenderContext.Provider value={isHydratingCompleted}>
<div>
<Switch>{renderRoutes(this.generateRoutingProps())}</Switch>
</div>
<Switch>{renderRoutes(this.generateRoutingProps())}</Switch>
</ReactRenderContext.Provider>
);
}
Expand Down
10 changes: 7 additions & 3 deletions src/universal/components/Html.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ function Html({
isMobileFragment,
context
}) {
return `
if (children) {
return `
<div>
${styleTags}
<script type='text/javascript'>${generateInitialState(initialState, componentName)}</script>
<div
id='${componentName.replace(/['"']+/g, '')}_${initialState.id}'
style="pointer-events: none;"
class="${voltranConfig.prefix}-voltran-body voltran-body ${
isMobileFragment ? 'mobile' : ''
}${fullWidth ? 'full' : ''} ${componentClassName(componentName, context)}">
isMobileFragment ? 'mobile' : ''
}${fullWidth ? 'full' : ''} ${componentClassName(componentName, context)}">
${children}
</div>
<div>REPLACE_WITH_LINKS</div>
Expand All @@ -55,6 +56,9 @@ function Html({
`<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0" />`
)}
</div>`;
}

return '';
}

export default Html;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect } from 'react';
import { useEffect } from 'react';

import withBaseComponent from '../../partials/withBaseComponent';
import { getEventBus } from '../../utils/helper';
Expand Down

0 comments on commit 81ef52f

Please sign in to comment.