snapguidist icon indicating copy to clipboard operation
snapguidist copied to clipboard

Add support for React 16.8 hooks

Open Acesmndr opened this issue 6 years ago • 3 comments

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

Acesmndr avatar Feb 07 '19 14:02 Acesmndr

Any progress on this one?

eduardoinnorway avatar Feb 20 '19 17:02 eduardoinnorway

need support react-styleguidist v9.x.x pls

Megoos avatar Feb 28 '19 15:02 Megoos

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 />

chrisregner avatar Jun 10 '20 20:06 chrisregner