const isInitialMount = useRef(true);
useEffect(() => {
if (isInitialMount.current) {
isInitialMount.current = false;
} else {
// Your useEffect code here to be run on update
}
});
import App from "./app.jsx";
import axios from "axios";
jest.mock("axios");
beforeEach(() => {
axios.create = jest.fn(() => axios);
axios.get.mockImplementation((url) => {
return Promise.resolve({
data: [{ id: 1, name: "books" }],
});
});
});
test("should display app", async () => {
render(<App />);
expect(await screen.findByText("books")).toBeInTheDocument();
});
.....
foreach ($request->input('products') as $product) {
return $product['id'];
}
public function store(ApplicantSkillsRequest $request)
{
$applicant = $request->user();
$params = $request->except('_token');
$levels = $request->level;
foreach($request->name as $i => $name) {
$skill = new ApplicantSkill;
$skill->user_id = $applicant->id;
$skill->name = $name;
$skill->level = $levels[$i];
$skill->save();
}
return redirect()->route('applicant.skills.index');
}