Updated github code to handle radio button (The article is not updated, but will do so when I grab some free time).08-June-2019 - Added getDerivedStateFromProps method.It’s a quick code, so there could be bugs.Īll validators can be stored in the validators folder. Even multiple validations on the same field are supported. Please share your thoughts, comments or anything that you think might help me creating more content :) Hope you enjoyed this small nugget of React code. I will be creating a hook version of this tutorial soon and these life cycle methods will be not needed. static getDerivedStateFromProps(nextProps, prevState) We, create a new id for the data (crude way to do so, but in real case the id’s are generated on the server) and finally update our state using set state.Īnd finally add the getDerivedStateFromProps method so that props changes triggers re-render of components. Let’s explore index.js and take a peek at the code. Inside DynamicForm folder, all the code for the components resides in index.js file and the styles are stored in form.css.įor simplicity I would not bother putting the styles here (but you can always refer the github for the same). Now I have created a folder with the following hierarchy Now comes the crux of the code, the DynamicForm, itself. The section simply renders the state information for completeness sake. Currently supports two types, default, text, and number.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |