Skip to content

Commit

Permalink
chore: code review
Browse files Browse the repository at this point in the history
  • Loading branch information
satazor committed Feb 27, 2020
1 parent f50b88a commit 40c749d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
File renamed without changes.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ The page component to wrap.

Type: `function`

Allows to dynamically change the layout state. Has the following signature: `(newState | updater?)`.
Allows dynamic changes to the layout state. Has the following signature: `(newState | updater?)`.

The behavior of `setLayoutState` is exactly the same as [`setState`](https://reactjs.org/docs/react-component.html#setstate) of class components: it merges properties and it supports both an object or an updater function.

Expand All @@ -228,8 +228,8 @@ import styles from './about.module.css';

const About = ({ setLayoutState }) => {
const handleSetToDark = useCallback(() => {
setLayoutState({ variant="dark" });
// ..or setLayoutState((layoutState) => ({ variant="dark" }));
setLayoutState({ variant: 'dark' });
// ..or setLayoutState((layoutState) => ({ variant: 'dark' }));
}, [setLayoutState]);

return (
Expand All @@ -242,7 +242,7 @@ const About = ({ setLayoutState }) => {

const mapLayoutStateToLayoutTree = ({ variant }) => <PrimaryLayout variant={ variant } />;

export default withLayout(mapLayoutStateToLayoutTree, { variant: "light" })(About);
export default withLayout(mapLayoutStateToLayoutTree, { variant: 'light' })(About);
```

## Tests
Expand Down
4 changes: 2 additions & 2 deletions src/LayoutTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export default class LayoutTree extends PureComponent {
static getDerivedStateFromProps(props, state) {
const { Component, pageProps } = props;

const didPageChanged = props.Component !== state.Component;
const layoutTree = didPageChanged ? getInitialLayoutTree(Component, pageProps) : state.layoutTree;
const didPageChange = props.Component !== state.Component;
const layoutTree = didPageChange ? getInitialLayoutTree(Component, pageProps) : state.layoutTree;

return {
Component,
Expand Down

0 comments on commit 40c749d

Please sign in to comment.