IssueRaiser

Warning: Cannot update a component (`xxx`) while rendering a different component (`xxx`).

A warning is occured where useRecoilValue() is used even though I write a code like one which is in the [official document here](https://recoiljs.org/docs/introduction/getting-started/#selector). <img width="516" alt="スクリーンショット 2020-05-15 4 55 26" src="https://user-images.githubusercontent.com/37825725/81980341-61841500-9669-11ea-9427-390d04645eca.png"> this is my code ``` import React, { useEffect } from 'react'; import { atom, useRecoilState, useRecoilValue, selector } from 'recoil'; function RecoilApp() { useEffect(() => { console.log('test'); }); return( <div> Recoil App <TextInput /> <CharCount /> </div> ); } const textState = atom({key: 'textState', default: ''}); function TextInput() { const [text, setText] = useRecoilState(textState); const onChange = event => { setText(event.target.value); } return( <div> <input type="text" value={text} onChange={onChange} /> <br /> Echo: {text} </div> ); }; function CharCount() { const count = useRecoilValue(countState); return <>Charset Count: {count}</>; } const countState = selector({ key: 'countState', get: ({get}) => { const text = get(textState); return text.length; }, }); export default RecoilApp; ```

Posted by syunto07ka on May 14, 2020, 8:10 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,500 issues0 comments

github (SaaS)

Warning: Cannot update a component (`xxx`) while rendering a different component (`xxx`).

syunto07kaMay 14, 2020, 8:10 PM

A warning is occured where useRecoilValue() is used even though I write a code like one which is in the [official document here](https://recoiljs.org/docs/introduction/getting-started/#selector). <img width="516" alt="スクリーンショット 2020-05-15 4 55 26" src="https://user-images.githubusercontent.com/37825725/81980341-61841500-9669-11ea-9427-390d04645eca.png"> this is my code ``` import React, { useEffect } from 'react'; import { atom, useRecoilState, useRecoilValue, selector } from 'recoil'; function RecoilApp() { useEffect(() => { console.log('test'); }); return( <div> Recoil App <TextInput /> <CharCount /> </div> ); } const textState = atom({key: 'textState', default: ''}); function TextInput() { const [text, setText] = useRecoilState(textState); const onChange = event => { setText(event.target.value); } return( <div> <input type="text" value={text} onChange={onChange} /> <br /> Echo: {text} </div> ); }; function CharCount() { const count = useRecoilValue(countState); return <>Charset Count: {count}</>; } const countState = selector({ key: 'countState', get: ({get}) => { const text = get(textState); return text.length; }, }); export default RecoilApp; ```

Comments (0)

No comments yet. Start the discussion.

Comment on this issue