Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for React 16.8 hooks #39

Open
Acesmndr opened this issue Feb 7, 2019 · 3 comments
Open

Add support for React 16.8 hooks #39

Acesmndr opened this issue Feb 7, 2019 · 3 comments

Comments

@Acesmndr
Copy link

Acesmndr commented Feb 7, 2019

Snapguidist throws an error in the browser console when we load a React.FunctionComponent with hooks in React Styleguidist. It doesn't break the compilation but throws an error onto the console.
React 16.8 was released just a day ago along with the hooks and snapguidist should add support for it as we are moving from class based components to function based components and hooks are necessary for adding state to the components.
screen shot 2019-02-07 at 8 03 50 pm

Without the snapguidist it works perfectly so I presume it's got to be a problem with either snapguidist or one of its dependencies.

Example:

import React, { useState } from 'react'
...
const Comp: React.FC<IComp> = props => {
  ...
  const [state, setState] = useState(0); 
  
  return <div onClick={() => { setState(state + 1) }}>{state}</div>;
};

This will throw the same error shown above

@eduardoinnorway
Copy link

Any progress on this one?

@Megoos
Copy link

Megoos commented Feb 28, 2019

need support react-styleguidist v9.x.x pls

@chrisregner
Copy link

chrisregner commented Jun 10, 2020

Probably obvious, but FYI to those who are looking, you can do this instead:

Input component

```js
const Test = () => {
  const [value, setValue] = require('react').useState('')
  return (<Input value={value} onChange={ev => setValue(ev.target.value)} />)
}
<Test />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants