revelrylabs / harmonium

An opinionated React component framework for teams that move fast.
https://harmonium.revelry.co
MIT License
35 stars 47 forks source link

Fix broken StatelessDrawer example #508

Closed derekjou closed 4 years ago

derekjou commented 4 years ago

I'm submitting a ...

Currently, the example for StatelessDrawer isn't displaying on the website and throws:

SyntaxError: Unexpected token (3:8)
1 : return (React.createElement(
2 : class StatelessDrawerExample extends Component {
3 :   state = { open: true };
            ^

Couldn't really find a reason this error is thrown other than maybe React.createElement doesn't like class components; however, it runs as a functional component!

I edited some lines up to work with hooks:

2 : StatelessDrawerExample() {
3 : const [open, setOpen] = React.useState(true);
6 :   setOpen(true);
10:   setOpen(false);
19 :           open={open}
20 :           close={closeDrawer}
21 :           expand={expandDrawer}
30 :               <a href='#about' onClick={(_e) => closeDrawer()}>About Item 1</a>
33 :               <a href='#about2' onClick={(_e) => closeDrawer()}>About Item 2</a>

and deleted the render method wrap since it's no longer a class component.

I tried these changes and it renders properly with these changes!

revelry-stalebot[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.