--- myst: html_meta: "description": "Using actions to manipulate the store and accessing the data from the store." "property=og:description": "Using actions to manipulate the store and accessing the data from the store." "property=og:title": "Use Actions To Manipulate The Store" "keywords": "Plone, training, exercise, solution, React, Redux" --- (actions-label)= # Use Actions To Manipulate The Store ## Wiring The Store Now that we have our store ready, it's time to connect the store to our code and remove all the unneeded functionality. The first step is to factor out the `Faq` component into a separate file called {file}`components/Faq.jsx`. It is almost an exact copy of {file}`App.js`: ```{code-block} jsx :emphasize-lines: 4,80 :linenos: true import { useState } from "react"; import FaqItem from "./FaqItem"; function Faq() { const [faqList, setFaqList] = useState([ { question: "What does the Plone Foundation do?", answer: "The mission of the Plone Foundation is to protect and...", }, { question: "Why does Plone need a Foundation?", answer: "Plone has reached critical mass, with enterprise...", }, ]); const [question, setQuestion] = useState(""); const [answer, setAnswer] = useState(""); const onDelete = (index) => { let faq = [...faqList]; faq.splice(index, 1); setFaqList(faq); }; const onChangeAnswer = (e) => { setAnswer(e.target.value); }; const onChangeQuestion = (e) => { setQuestion(e.target.value); }; const onEdit = (index, question, answer) => { const faq = [...faqList]; faq[index] = { question, answer }; setFaqList(faq); }; const onSubmit = (e) => { e.preventDefault(); setFaqList([...faqList, { question, answer }]); setQuestion(""); setAnswer(""); }; return (