=========================================== ReactJS to manage the list of categories =========================================== In this sample we will write a simplistic web page utilizing ReactJS to manage a list of items - the data source categories. - We will use the :ref:`GET_advancedSetting/category/(tenant_id)`, :ref:`POST_advancedSetting/category` and :ref:`DELETE_advancedSetting/category/{category_id}` APIs. - We will use ReactJS to create the UI. Prerequisites ------------- #. This sample is a continuation of :doc:`code_react_manage_a_scalar_value`. #. This sample re-uses the folder structure created in :doc:`code_react_manage_a_scalar_value`. #. The uncompressed, development version of react.js and react-dom.js has been put into "ui\_react\_examples/vendor" folder. (They are in the starter kit available at https://facebook.github.io/react/downloads.html) Boilerplate code for an array ----------------------------- With these APIs, we will be managing an array of objects, so: - We model the data in ``this.state`` in an array called categoryArray. - We modify render method to display a list of items - We render a new Add button to insert a new category - We modify reflectChangedData method to update categoryArray with user input. We also make one code improvement to pass the API server IP and port via the parameter rootUrl to the ReactJS component. #. In "ui\_react\_examples" folder, create a blank text file and name it "ReactJS to manage the list of categories.html". #. Edit the file with a text editor such as Notepad or Notepad++ and paste the following boilerplate HTML code: .. comment: highlight as text since Pygments cannot parse jsx .. code-block:: text
.. note:: If using Notepad++, we can set the Language as JavaScript to see proper syntax highlighting. - We render the list of categories in an unordered list ``