ReactJS Context

In ReactJS, if you want to share the data between two or more components, you need to keep that data to their component which is parent component and then you pass that data in the form of properties. If you want to share the same data to further down components, you need to do the same.
Its method is to manage state or data which can be shared among multiple components.
You can pass this data to components without using Props.

Tags

ReactJS - Update state (Complex state) having array values

Normally, state of ReactJS component may have many state properties/constants/variables to hold values after something is done. If state object has one value, than is very easy to update this value using setXXX function. But if the state has Array type values, than you need to merge the values. To merge the values, you need to pull previous values, extract them and create new array using the old values and new value. Then set the new update array back to state.

Tags

Dockerfile - executing shell script file on Entrypoint

While creating auto deployment process, sometime it is needed that you will have to run bash shell script on Entrypoint or at starting point of container. Like you may need to execute multiple commands at start point of container which is not easy to do that. But fortunetly , you can add shell script file in Entrypoint and it will get executed.

Here is the example how you can run shell script from file on Entrypoint in dockerfile.

init.sh file

Tags

Drupal 8 or 9 - Webform - Searching and loading submission using form fields value

In Drupal, sometime we need to deal with already submitted form data. E.g. we may give end user to display some values of submitted records based on provided phone number or any other field.

For this, we would use Drupal database service which would allow us to build select query. In select query , you can mention fields you want to fetch and conditions to filter the data.

And if you fetch submission Id, then you can load the entire submission data.

Here is the code sample.

 

Tags