Change:
I've noticed a strange bug with the react redux opt-in. If i use it with a connected class component, everything is ok: If i use it with a connected functional component that use with , i obtain a strange error: in method. I create a codepen to reproduce the issue: PS: Sorry for the cors error, but i don't find the way to add as cdn
I believe the issue here is that expects the second argument to be a function that returns the reference: See: for more information about the API of the hook. Maybe the error thrown could be more clear?
You're right, accept a function as second argument. A warning on wrong argument type could be a good idea.
Ill take this issue on
Sure
i get TypeError: React.useImperativeMethods is not a function in 16.8.0-alpha.1 but when back to 16.7.0-alpha.2 not get this error
The hook was renamed in this PR: Most likely between the 16.7 alpha and 16.8 alpha
Yeah, it was renamed.
yes it work good after rename it where i can get changes between alpha version ?
Commit log. We don't write changelogs for alphas.
I'm taking this in since we want to get Hooks out sooner.
alright np

Discussion:
): void { if (__DEV__) { currentHookNameInDev = 'useImperativeHandle'; <ins> warning( typeof create === 'function', 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: %s.', create !== null ? typeof create : 'null', ); </ins> } // TODO: If deps are provided, should we skip comparing the ref itself? const nextDeps =

return () => refCallback(null); } else if (ref !== null && ref !== undefined) { const refObject = ref; <ins> if (__DEV__) { warning( refObject.hasOwnProperty('current'), 'Expected useImperativeHandle() first argument to either be a ' + 'ref callback or React.createRef() object. Instead received: %s.', 'an object with keys {' + Object.keys(refObject).join(', ') + '}', ); } </ins> const inst = create(); refObject.current = inst; return () => {

} } while (nextEffect !== null) { <ins> if (__DEV__) { setCurrentFiber(nextEffect); } </ins> const effectTag = nextEffect.effectTag; if (effectTag & (Update | Callback)) {

nextEffect = nextEffect.nextEffect; } <ins> if (__DEV__) { resetCurrentFiber(); } </ins> } function commitPassiveEffects(root: FiberRoot, firstEffect: Fiber): void {

let effect = firstEffect; do { <ins> if (__DEV__) { setCurrentFiber(effect); } </ins> if (effect.effectTag & Passive) { let didError = false; let error;

} effect = effect.nextEffect; } while (effect !== null); <ins> if (__DEV__) { resetCurrentFiber(); } </ins> isRendering = previousIsRendering;

]); }); <ins> it('warns for bad useImperativeHandle first arg', () => { const {useImperativeHandle} = React; function App() { useImperativeHandle({ focus() {}, }); return null; } expect(() => { expect(() => { ReactTestRenderer.create(<App />); }).toThrow('create is not a function'); }).toWarnDev([ 'Expected useImperativeHandle() first argument to either be a ' + 'ref callback or React.createRef() object. ' + 'Instead received: an object with keys {focus}.', 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: undefined.', ]); }); it('warns for bad useImperativeHandle second arg', () => { const {useImperativeHandle} = React; const App = React.forwardRef((props, ref) => { useImperativeHandle(ref, { focus() {}, }); return null; }); expect(() => { ReactTestRenderer.create(<App />); }).toWarnDev([ 'Expected useImperativeHandle() second argument to be a function ' + 'that creates a handle. Instead received: object.', ]); }); </ins> // https://github.com/facebook/react/issues/14022 it('works with ReactDOMServer calls inside a component', () => { const {useState} = React;