小编use*_*366的帖子

如何更新 REACTJS 中由数组映射渲染的输入文本

const data = [\n  {\n    title: "Hello World",\n    company: [\n      "Google",\n      "Apple",\n      "Facebook"\n    ]\n  }\n];\n\nclass App extends React.Component {\n  render() {\n    return (\n \xc2\xa0 \xc2\xa0 \xc2\xa0<ul>\n \xc2\xa0 \xc2\xa0 \xc2\xa0  {data[0].company.map((item, index) => (\n \xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0<input type="text" key={index} value={item}></input>\n \xc2\xa0 \xc2\xa0 \xc2\xa0  ))}\n \xc2\xa0 \xc2\xa0 \xc2\xa0</ul>\n \xc2\xa0  );\n  }\n}\n\nReactDOM.render(<App />, document.getElementById("app"));\n
Run Code Online (Sandbox Code Playgroud)\n\n

它呈现完美,但是当我尝试编辑它时,\n 不编辑文本。(不可编辑)\n 如果我向具有空白区域 \n 值的同一数组再添加一个输入,它也不起作用(未更新)。

\n

javascript arrays reactjs

6
推荐指数
2
解决办法
7953
查看次数

&lt;Provider&gt;中的错误-检查`Provider`的渲染方法。react-redux

在此处输入图片说明在此处输入图片说明

代码:这是我的index.js文件

index.js

    import { Provider } from "react-redux";
    import { createStore } from 'redux';

    import App from './app';

    import reducer from './store/reducer';

    const store = createStore(reducer);
    console.log("Store ..."+store);
    console.log(Provider);

    ReactDOM.render((
      <Provider store={store}>
        <App/>
      </Provider>
    ), document.getElementById('root'));
Run Code Online (Sandbox Code Playgroud)

代码:这是我的reducer.js文件

    reducer.js
    import * as actionTypes from './actions';

    const initialState = {
    assistants:[],
    fetchInProgress:true
    }

    const reducer = (state = initialState, action) =>{

    return state;
    };

    export default reducer;
Run Code Online (Sandbox Code Playgroud)

代码:这是我的app.js文件app.js

class App extends Component{
render(){
return(
  <HashRouter>
    <Switch>
    <Route exact path="/login" name="Login Page" …
Run Code Online (Sandbox Code Playgroud)

redux redux-thunk redux-saga react-redux react-router-redux

4
推荐指数
2
解决办法
1346
查看次数