What is React Storybook and React addons part 1

I will cover a few advanced what is what is the done and the most popular are done the don’ts and what I use often is extra nobs react I have added in the neutralization and accessibility plus Isa some demo how it works in configured environment so let’s discuss what is storybook and why do we need it storybook it’s some kind of environment where you can test your components and develop them in the pan Liam and each component will be developed independently and you can check.

How it will looks with different probes with different styles with different parameters and it will be not related to your application so it’s very great approach for developing nuclei components you are library where you need to check each company independently and how it will looks in different states with different probes okay watch the story book we can visit storybook jazz or aside at first all we need to install the storybook I will use storybook for small reactor plication we see few components and then it will help me to check a few components what I want to test your install we need to install storybook here we have a few options we can install for HTML or for different environments or libraries I’m going to pass any type it will find without environment of tamale okay and install proper motion.

So that’s installed okay so now we see that everything is installed successfully we can check changes in our application so let’s openpackage.json here we can see a few additional commas in scripts it’s storybook and build storybook also we can see that we have a few devdependencies additional it’s a dance the photo Don’s actions and the storybook react also we can see that we have a new folder it’s storybook with two files it’s confit and advance let’s try to run it and see what’s happening or still we need call command we will call kamahi on storybook and we will check on what were known and how it looks we load in cover story book and here we can see that it’s right it’s empty storybook but we have some demo component it’s text and image text now we can see how it looks also we can see that I don’t actually already works we can see that it was clicked and weak we can check what lot of properties of this click event so.

This one works fine let’s check how it looks inside so in our configuration file we see that all stories allocated in source stories let’s open it a herewe has these new folders tourism here we can see that we have some default information to story it’s our first welcome part and also we have another one button story for button here consist we have two different stories it’s text explore text and emoji button so let’s change it a bit right now we have ours our stories in different folders stories but them as much that we have a huge amount of companies and for all companies and all kids everything will be in one folder and it looks not too very nice I prefer to split it in different components so for example we have one layout component it’s a component we want to test with storybook so that’s great to hear folder stories and you can add optional what is related to this component all stores you will stored here so let’s create a copy okay let’s test it first all we did create an empty file into Jason stories and we’ll put some basic story empties they are to be here we’ll import over concurrently out and try to adhere with some small text and we would like to test it here but right now we won’t see anything any changes here because we need to change some configuration in our storybook so let’s open storybook and change this conflict so we want open not two stories folder but.

We want to see everything and here we won’t check everything what is saved in story storage folder let’s change it to this one and after that two story book will automatically reboot and let’s check how it works and here we see that we already have layout component and here we see our text component all right now it’s without any probes or any styles and it loaded successfully let’s add at least the first additional add-on it notes call it calls it’s done for passing different probes and then we can test this company and then we will test this component much better so to add these add-onset need them okay so let’s check what is this is done so let’s open it and check how it should be configured so we need added after that we can see that here Isa simple configuration for each component and also do not forget to impede purchased done in add-ons J’s file let’s add it here while holding and we can try this component here okay so here.

We had a bull Bullard property let’s check it also in our component because here we have the same property default value is false this we do not need hereof the next what we need you we need to add the decorator the grater with knobs so how can we do it we can edit it right here right here now socially will add decorator with notes and then we will reload and right now it works fine let’s open our storybook reload storybook you can reload it from the scratch and check how it works okay it’s reloaded so we have our text company and here we can see that we have this additional add-on it nobs with the property what we added it’s loading probes and it’s bullying so we can check how it works and here as you see when we click it’s loaded true this is that this component is changed rivet for loading state it’s what was expected and so we can see that we have is loading probes and it’s Boolean checkbox so when we chicken thesis at our component change.

State for loading it’s it what was expected behavior so let’s check what we can do it next one I would add I would like to add the story shot so as we know react has a snapshot testing it takes the component build it hormone to it and save snapshot of this component to file and then it can be checked if subsequent change so we storybook we Cando the same but automatically we don’t need to create stock create test for each component for each story it will be created automatically so what do we need to do okay so let’s configure story shots for our application so let’s open documentation for the story shut it down and let’s do orange first all we need to add the story shots to our dependencies let’s install this model okay the next unit configure our confit file change it a bit so let’s copy and open the confit file and change it for read next step we need to install Babel plugin require context hook it’s required port and to work with we created just folder and then.

We need to add the register a context hook phone function and it should to help just to run unit tests properly and create snapshots so let’s create this folder I also hear you calculate file with another name I will put some chance it will be fine and here in this file we will put the next coat its configuration for NZ and then adapter react extreme and this is hook I’ll edit I guess we need install this one but this dependency and to the next important part it’s a Babel configuration because without this ironmen plugins part it don’t work so we need to add babel there zip file and here in this file put the next chord it will be present plug-in and what we need it’s and wire and test like in Cîroc contacts hook and they were pocket dynamic input node it’s required just leave it here and here mentions that we need to dishrag test renderer let’s edit then we go check how it works ok and here we need to fix this error and by mistaken.

Leave a Comment

Your email address will not be published. Required fields are marked *