Skip to content

Commit

Permalink
Add test for useHelmet() hook
Browse files Browse the repository at this point in the history
  • Loading branch information
kouhin committed May 17, 2019
1 parent 78d3923 commit 87845ab
Show file tree
Hide file tree
Showing 5 changed files with 4,882 additions and 22 deletions.
15 changes: 1 addition & 14 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@
"rules": {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error",
"prettier/prettier": [
"error",
{
"printWidth": 80,
"tabWidth": 4,
"singleQuote": false,
"trailingComma": "none",
"bracketSpacing": false,
"semi": true,
"useTabs": false,
"parser": "babel",
"jsxBracketSameLine": false
}
]
"prettier/prettier": "error"
}
}
11 changes: 11 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"printWidth": 80,
"tabWidth": 4,
"singleQuote": false,
"trailingComma": "none",
"bracketSpacing": false,
"semi": true,
"useTabs": false,
"parser": "babel",
"jsxBracketSameLine": false
}
13 changes: 6 additions & 7 deletions src/Helmet.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ function generateUniqueString() {
);
}

function useHelmet(props) {
function useHelmet(props = {}) {
const instance = useMemo(() => generateUniqueString(), []);
const dispatch = useContext(HelmetContext);
const called = useRef(false);
Expand All @@ -291,7 +291,11 @@ function useHelmet(props) {
}
prevProps.current = props;
const {children, ...restProps} = props;
let newProps = {...restProps};
let newProps = {
defer: true,
encodeSpecialCharacters: true,
...restProps
};
if (children) {
newProps = mapChildrenToProps(children, newProps);
}
Expand Down Expand Up @@ -321,11 +325,6 @@ const Helmet = props => {

Helmet.displayName = "Helmet";

Helmet.defaultProps = {
defer: true,
encodeSpecialCharacters: true
};

if (process.env.NODE_ENV !== "production") {
/**
* @param {Object} base: {"target": "_blank", "href": "http://mysite.com/"}
Expand Down
Loading

0 comments on commit 87845ab

Please sign in to comment.