Answer the question
In order to leave comments, you need to log in
Why is undefined being passed to my props?
There is a React application code
Entry point:
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import reducer from './store/reducers'
import App from './App.js';
let store = createStore(reducer);
render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
);
export default const taskReducer = (state = [], action) => {
switch (action.type) {
case 'ADD_TASK':
return [...state,
action.payload];
break;
default:
return state;
}
}
import React from 'react'
import { connect } from 'react-redux'
class App extends React.Component {
render() {
console.log(this.props.entryText) // undefined!
return (
<div>
<input type='text' placeholder='Add your task here' />
<button >Add</button>
</div>
)
}
}
export default connect(state => {entryText: state }, dispatch => { })(App)
Answer the question
In order to leave comments, you need to log in
// Вот так вот попробуй
export default connect(state => ({entryText: state }), dispatch => { })(App)
// Вместо
// export default connect(state => {entryText: state }, dispatch => { })(App)
when you inherit, you need to call the constructor of the base class
constructor(){
super();
}
It is best to use the native language of the system (performance, stability, predictability).
If you need to fumble code between platforms, it makes sense to look towards xamarin .
I made an HTML & JS application using Backbone, it certainly worked, but then I rewrote it in Java.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question