generated from ibm-developer-skills-network/coding-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Open
Description
Hello,
I copied the code block for the budget.js file. Anyways when I run the website the budget state will not be updated in the context. Therefore I changed the file to this.
import { AppContext } from '../context/AppContext';
const Budget = () => {
const { budget, dispatch } = useContext(AppContext);
const [newBudget, setNewBudget] = useState(budget);
const handleBudgetChange = (event) => {
setNewBudget(event.target.value);
dispatch({
type: 'SET_BUDGET',
payload: event.target.value
});
}
return (
<div className='alert alert-secondary'>
<span>Budget: £{budget} </span>
<input type="number" step="10" value={newBudget} onChange={handleBudgetChange}></input>
</div>
);
};
export default Budget;
Here I just added the dispatch function, because in the tutorial there is none. Please let me know if I am wrong or if this is a real issue in your repo.
Best Regards,
David
YuKitAs and Irascibleardent
Metadata
Metadata
Assignees
Labels
No labels