Reactjs 警告:无法在现有状态转换期间更新(例如在“渲染”中)
我不明白怎么了,因为在我看来一切都很好。控制台中有以下警告: 警告:无法在现有状态转换期间更新(例如 在Reactjs 警告:无法在现有状态转换期间更新(例如在“渲染”中),reactjs,flux,reactjs-flux,Reactjs,Flux,Reactjs Flux,我不明白怎么了,因为在我看来一切都很好。控制台中有以下警告: 警告:无法在现有状态转换期间更新(例如 在渲染中)。渲染方法应该是道具的纯功能 和国家 在守则中,我有: 在Index.js中: import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; import reportWebVitals from './reportWebVitals'; import EnvAnimation from
渲染中
)。渲染方法应该是道具的纯功能
和国家
在守则中,我有:
在Index.js中:
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import EnvAnimation from "./containers/AppContainer";
ReactDOM.render(EnvAnimation(App), document.getElementById('root'))
import React from 'react'
import {Container} from 'flux/utils';
import checkboxesStore from "../data/checkboxes/checkboxesStore";
import CSSRootStore from "../data/CSSRoot/CSSRootStore";
import "../impAnimation.css"
function getStores() {
return [
checkboxesStore,
CSSRootStore
]
}
function getState() {
return {
checkboxes: {
state: checkboxesStore.getState()
}
}
}
let View
export default function EnvAnimation (view) {
const Env = Container.createFunctional(ViewEnv, getStores, getState)
View = view
return <Env/>
}
function ViewEnv (props) {
console.log(props)
return (
<View {...props}/>
)
}
import logo from './logo.svg';
import './App.css';
import React from 'react'
import imp, {getCheckboxes} from './imp'
function App (props) {
const checkbox = getCheckboxes('checkbox01')
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<imp.checkboxes entry={'in'} id="checkbox01" checks={2} limit={2} {...props}
onClick={ () => { checkbox.setIterations('infinite') }}>
CIAO
</imp.checkboxes>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
)
}
export default App
import checkboxes, { setEntry as SetCheckboxesEntry, setEntryDirection as setCheckboxesEntryDirection } from './components/checkboxes'
import checkboxesObject from './data/checkboxes/checkboxesObject'
import getAnimationData from "./view";
const imp = {
checkboxes: checkboxes
}
export function getCheckboxes(id) {
const retObject = {
...getAnimationData('checkboxes', id, checkboxesObject)
}
retObject.setEntry = SetCheckboxesEntry
retObject.setEntryDirection = setCheckboxesEntryDirection
return retObject
}
export default imp
在AppContanier.js中:
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import EnvAnimation from "./containers/AppContainer";
ReactDOM.render(EnvAnimation(App), document.getElementById('root'))
import React from 'react'
import {Container} from 'flux/utils';
import checkboxesStore from "../data/checkboxes/checkboxesStore";
import CSSRootStore from "../data/CSSRoot/CSSRootStore";
import "../impAnimation.css"
function getStores() {
return [
checkboxesStore,
CSSRootStore
]
}
function getState() {
return {
checkboxes: {
state: checkboxesStore.getState()
}
}
}
let View
export default function EnvAnimation (view) {
const Env = Container.createFunctional(ViewEnv, getStores, getState)
View = view
return <Env/>
}
function ViewEnv (props) {
console.log(props)
return (
<View {...props}/>
)
}
import logo from './logo.svg';
import './App.css';
import React from 'react'
import imp, {getCheckboxes} from './imp'
function App (props) {
const checkbox = getCheckboxes('checkbox01')
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<imp.checkboxes entry={'in'} id="checkbox01" checks={2} limit={2} {...props}
onClick={ () => { checkbox.setIterations('infinite') }}>
CIAO
</imp.checkboxes>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
)
}
export default App
import checkboxes, { setEntry as SetCheckboxesEntry, setEntryDirection as setCheckboxesEntryDirection } from './components/checkboxes'
import checkboxesObject from './data/checkboxes/checkboxesObject'
import getAnimationData from "./view";
const imp = {
checkboxes: checkboxes
}
export function getCheckboxes(id) {
const retObject = {
...getAnimationData('checkboxes', id, checkboxesObject)
}
retObject.setEntry = SetCheckboxesEntry
retObject.setEntryDirection = setCheckboxesEntryDirection
return retObject
}
export default imp
在imp.js中:
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import EnvAnimation from "./containers/AppContainer";
ReactDOM.render(EnvAnimation(App), document.getElementById('root'))
import React from 'react'
import {Container} from 'flux/utils';
import checkboxesStore from "../data/checkboxes/checkboxesStore";
import CSSRootStore from "../data/CSSRoot/CSSRootStore";
import "../impAnimation.css"
function getStores() {
return [
checkboxesStore,
CSSRootStore
]
}
function getState() {
return {
checkboxes: {
state: checkboxesStore.getState()
}
}
}
let View
export default function EnvAnimation (view) {
const Env = Container.createFunctional(ViewEnv, getStores, getState)
View = view
return <Env/>
}
function ViewEnv (props) {
console.log(props)
return (
<View {...props}/>
)
}
import logo from './logo.svg';
import './App.css';
import React from 'react'
import imp, {getCheckboxes} from './imp'
function App (props) {
const checkbox = getCheckboxes('checkbox01')
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<imp.checkboxes entry={'in'} id="checkbox01" checks={2} limit={2} {...props}
onClick={ () => { checkbox.setIterations('infinite') }}>
CIAO
</imp.checkboxes>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
)
}
export default App
import checkboxes, { setEntry as SetCheckboxesEntry, setEntryDirection as setCheckboxesEntryDirection } from './components/checkboxes'
import checkboxesObject from './data/checkboxes/checkboxesObject'
import getAnimationData from "./view";
const imp = {
checkboxes: checkboxes
}
export function getCheckboxes(id) {
const retObject = {
...getAnimationData('checkboxes', id, checkboxesObject)
}
retObject.setEntry = SetCheckboxesEntry
retObject.setEntryDirection = setCheckboxesEntryDirection
return retObject
}
export default imp