Tell us what’s happening:
The problem is not actually on this challenge, I think it works properly. Problem is that I tried to simulate this challenge on codepen, and it doesn’t work (it just shows nothing but saas). I added those links in js(babel) section:
https://cdnjs.cloudflare.com/ajax/libs/react/16.9.0/umd/react.production.min.js
//cdnjs.cloudflare.com/ajax/libs/react/0.13.0/react.min.js
https://cdnjs.cloudflare.com/ajax/libs/react-redux/5.0.5/react-redux.min.js
https://cdnjs.cloudflare.com/ajax/libs/redux/3.7.1/redux.min.js
Sorry for asking question that is not directly related to fCC challenges.
Your code so far
<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
<div id="app"></div>
// Redux Code:
const ADD = 'ADD';
const addMessage = (message) => {
return {
type: ADD,
message
}
};
const messageReducer = (state = [], action) => {
switch (action.type) {
case ADD:
return [
...state,
action.message
];
default:
return state;
}
};
const store = Redux.createStore(messageReducer);
// React Code:
class DisplayMessages extends React.Component {
constructor(props) {
super(props);
this.state = {
input: '',
messages: []
}
this.handleChange = this.handleChange.bind(this);
this.submitMessage = this.submitMessage.bind(this);
}
handleChange(event) {
this.setState({
input: event.target.value
});
}
submitMessage() {
const currentMessage = this.state.input;
this.setState({
input: '',
messages: this.state.messages.concat(currentMessage)
});
}
render() {
return (
<div>
<h2>Type in a new Message:</h2>
<input
value={this.state.input}
onChange={this.handleChange}/><br/>
<button onClick={this.submitMessage}>Submit</button>
<ul>
{this.state.messages.map( (message, idx) => {
return (
<li key={idx}>{message}</li>
)
})
}
</ul>
</div>
);
}
};
const Provider = ReactRedux.Provider;
class AppWrapper extends React.Component {
// render the Provider here
render(){
return(
<Provider store={store}>
<DisplayMessages/>
</Provider>)}
// change code above this line
};
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36.
Link to the challenge: