Skip to content

Commit

Permalink
revert defaultProps change
Browse files Browse the repository at this point in the history
  • Loading branch information
utku-ozturk committed Aug 15, 2024
1 parent 68b33d6 commit dcb19b2
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 50 deletions.
61 changes: 35 additions & 26 deletions es/components/static-pages/StaticPageBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,32 +224,8 @@ export var StaticPageBase = /*#__PURE__*/function (_React$PureComponent2) {
key: "render",
value: function render() {
var _this$props2 = this.props,
_this$props2$context = _this$props2.context,
context = _this$props2$context === void 0 ? {
title: "Page Title",
content: {
sectionNameID1: {
order: 0,
title: "Section Title 1",
content: "<h2>Hello</h2>",
filetype: "html"
},
sectionNameID2: {
order: 1,
title: "Section Title 2",
content: "<h2>World</h2>",
filetype: "html"
}
}
} : _this$props2$context,
_this$props2$entryRen = _this$props2.entryRenderFxn,
entryRenderFxn = _this$props2$entryRen === void 0 ? memoize(function (sectionName, section, props) {
return /*#__PURE__*/React.createElement(StaticEntry, _extends({}, props, {
key: sectionName,
sectionName: sectionName,
section: section
}));
}) : _this$props2$entryRen,
context = _this$props2.context,
entryRenderFxn = _this$props2.entryRenderFxn,
contentParseFxn = _this$props2.contentParseFxn,
CustomWrapper = _this$props2.CustomWrapper;
var parsedContent = null;
Expand Down Expand Up @@ -298,6 +274,39 @@ export var StaticPageBase = /*#__PURE__*/function (_React$PureComponent2) {
}]);
}(React.PureComponent);
_defineProperty(StaticPageBase, "Wrapper", Wrapper);
_defineProperty(StaticPageBase, "defaultProps", {
"context": {
"title": "Page Title",
"content": {
"sectionNameID1": {
"order": 0,
"title": "Section Title 1",
"content": "<h2>Hello</h2>",
"filetype": "html"
},
"sectionNameID2": {
"order": 1,
"title": "Section Title 2",
"content": "<h2>World</h2>",
"filetype": "html"
}
}
},
/**
* Default function for rendering out parsed section(s) content.
*
* @param {string} sectionName - Unique identifier of the section. Use to navigate to via '#<sectionName>' in URL.
* @param {{ content : string|JSX.Element }} section - Object with parsed content, title, etc.
* @param {Object} props - Collection of props passed down from BodyElement.
*/
'entryRenderFxn': memoize(function (sectionName, section, props) {
return /*#__PURE__*/React.createElement(StaticEntry, _extends({}, props, {
key: sectionName,
sectionName: sectionName,
section: section
}));
})
});
_defineProperty(StaticPageBase, "propTypes", {
'context': PropTypes.shape({
"title": PropTypes.string,
Expand Down
57 changes: 33 additions & 24 deletions src/components/static-pages/StaticPageBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,38 @@ export class StaticPageBase extends React.PureComponent {
);
}

static defaultProps = {
"context" : {
"title" : "Page Title",
"content" : {
"sectionNameID1" : {
"order" : 0,
"title" : "Section Title 1",
"content" : "<h2>Hello</h2>",
"filetype" : "html"
},
"sectionNameID2" : {
"order" : 1,
"title" : "Section Title 2",
"content" : "<h2>World</h2>",
"filetype" : "html"
}
}
},

/**
* Default function for rendering out parsed section(s) content.
*
* @param {string} sectionName - Unique identifier of the section. Use to navigate to via '#<sectionName>' in URL.
* @param {{ content : string|JSX.Element }} section - Object with parsed content, title, etc.
* @param {Object} props - Collection of props passed down from BodyElement.
*/
'entryRenderFxn' : memoize(function(sectionName, section, props){
return (
<StaticEntry {...props} key={sectionName} sectionName={sectionName} section={section} />
);
})
};

static propTypes = {
'context' : PropTypes.shape({
Expand All @@ -217,30 +249,7 @@ export class StaticPageBase extends React.PureComponent {
};

render() {
const {
context = {
title: "Page Title",
content: {
sectionNameID1: {
order: 0,
title: "Section Title 1",
content: "<h2>Hello</h2>",
filetype: "html"
},
sectionNameID2: {
order: 1,
title: "Section Title 2",
content: "<h2>World</h2>",
filetype: "html"
}
}
},
entryRenderFxn = memoize((sectionName, section, props) => (
<StaticEntry {...props} key={sectionName} sectionName={sectionName} section={section} />
)),
contentParseFxn,
CustomWrapper
} = this.props;
const { context, entryRenderFxn, contentParseFxn, CustomWrapper } = this.props;

let parsedContent = null;
try {
Expand Down

0 comments on commit dcb19b2

Please sign in to comment.