{"id":30745,"date":"2023-02-15T08:00:00","date_gmt":"2023-02-15T16:00:00","guid":{"rendered":"https:\/\/coderpad.io\/?p=30745"},"modified":"2023-08-04T13:18:36","modified_gmt":"2023-08-04T20:18:36","slug":"code-challenge-react-context-api-array-toggle","status":"publish","type":"post","link":"https:\/\/coderpad.io\/blog\/coding-challenges\/code-challenge-react-context-api-array-toggle\/","title":{"rendered":"Code Challenge: React Context API Array Toggle"},"content":{"rendered":"\n<p>React context API allows developers to pass data through a component tree without having to pass props manually at every level. React&#8217;s context API finds its usage in large application components required to share data at different nesting levels.<\/p>\n\n\n\n<p>For this tiny interview, a JavaScript array containing foods have been provided, use this array to implement a feature that enables the content of the array to be toggled using the React Context API.<\/p>\n\n\n\n<p>Implement your solution in the sandbox below:<\/p>\n\n\n<div\n\tclass=\"sandbox-embed responsive-embed  sandbox-embed--full-width\"\n\tstyle=\"padding-top: 125%\"\ndata-block-name=\"coderpad-sandbox-embed\">\n\t<iframe src=\"https:\/\/embed.coderpad.io\/sandbox?question_id=240942&#038;use_question_button\" width=\"640\" height=\"800\" loading=\"lazy\" aria-label=\"Try out the CoderPad sandbox\"><\/iframe>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Want some more challenge?<\/h2>\n\n\n\n<p>If you completed the original goal, why not try the following bonus exercise?<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Allow more foods to be added to be added to the foods array by providing a custom controlled input component.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Code challenge solution<\/h2>\n\n\n\n<p>Verify your solution with the official solution in this\u00a0<a href=\"https:\/\/app.coderpad.io\/sandbox?question_id=240943\">sandbox<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">More resources<\/h2>\n\n\n\n<p>We have made available these extra resources to improve your React coding skills:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/coderpad.io\/interview-questions\/react-interview-questions\/\">25+ React interview questions<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/coderpad.io\/online-coding-tests\/react\/\">Online coding test questions for React<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"markdown-want-to-conduct-interviews-on-this-platform\">Want to conduct interviews on this platform?<\/h2>\n\n\n\n<p>Check out CoderPad : pick any interview question or create your own, then invite your candidate to a shared live-coding session on an IDE like this one. You even get 2 free interviews per month forever using&nbsp;<a href=\"https:\/\/app.coderpad.io\/register?source=Tiny+Interviews\">this registration link<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>React context API allows developers to pass data through a component tree without having to pass props manually at every level. Test your knowledge of the React&#8217;s Context API by improving the application in this tiny interview.<\/p>\n","protected":false},"author":1,"featured_media":30748,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[22],"tags":[],"persona":[29],"blog-programming-language":[61],"keyword-cluster":[],"class_list":["post-30745","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-coding-challenges"],"acf":[],"_links":{"self":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/posts\/30745","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/comments?post=30745"}],"version-history":[{"count":25,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/posts\/30745\/revisions"}],"predecessor-version":[{"id":35861,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/posts\/30745\/revisions\/35861"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/media\/30748"}],"wp:attachment":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/media?parent=30745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/categories?post=30745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/tags?post=30745"},{"taxonomy":"persona","embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/persona?post=30745"},{"taxonomy":"blog-programming-language","embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/blog-programming-language?post=30745"},{"taxonomy":"keyword-cluster","embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/keyword-cluster?post=30745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}