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"));\nRun Code Online (Sandbox Code Playgroud)\n\n它呈现完美,但是当我尝试编辑它时,\n 不编辑文本。(不可编辑)\n 如果我向具有空白区域 \n 值的同一数组再添加一个输入,它也不起作用(未更新)。
\n代码:这是我的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)