Larry Krasner wants to fix America's criminal justice system, which imprisons more people per capita than any other country on the planet. Since 2018, he served as the district attorney of Philadelphia, one of America's most highly incarcerated and, as of late, increasingly crime-ridden cities. Krasner spent three decades as a criminal and civil rights defense attorney before deciding to run for office. Our movement did the uncomfortable thing. We took back power, he wrote in a memoir about his successful 2017 run for Philadelphia's district attorney. We outsiders went inside and took over the institution we had fought against all our lives. In his first week as DA, Krasner fired 31 staffers and replaced them with a new team that he described as ideologically attached to the mission. It's a pretty basic mission for people who are in favor of freedom. One of those missions is to be less incarcerated than Vladimir Putin's Russia. I don't think that should be very controversial, apparently it is, but it seems to me that that's basic. Another aspect of the mission is not to have what I would call the ultimate form of big government, which is to be the most incarcerated country in the world without a perceptible increase in safety. Krasner easily won re-election last year, but today he's under intense pressure because Philly posted a record 562 murders in 2021, and it's on pace for a similar outcome in 2022. The Republican-led state legislature has become impeachment proceedings against him. Reason sat down with Krasner in his office to talk about his reforms, the violent crime spike, the heat that progressive prosecutors are feeling in cities like Los Angeles and San Francisco, and what that means for the future of the American criminal justice reform movement. You spent decades as a basically civil rights defense attorney, and now you are the city's top prosecutor. What made you decide to pursue that in 2017? When I came out of law school, I think I was a little bit naive, and I believed that if you just did really good work either as a prosecutor or defense attorney, I actually started out as a state public defender in that under-resourced rodeo that Justice Sotomayor talked so much about. I believe that if you were on either side, you could do really good work, and that the system wasn't broken. What I found out over 30 years is that in many ways it really is, and those were the same 30 years when much of the rise of mass incarceration occurred. I got to the point when I was 56 where I felt like in order to have a much more sweeping impact on a system that I thought was profoundly broken, I had to do something else, and that's when I decided to run to be a chief prosecutor in Philly. And can you talk a little bit about Philadelphia specifically because I know that, for instance, the youth incarceration rate was high compared to even other big American cities. I mean, what was the situation that you were coming into in this city that you felt was needing to be urgently addressed? So the crazy irony of Philly is that this is a tourist destination for freedom. Liberty Bell, you know, place where they wrote the Declaration of Independence, the Constitution, all of that is here. And yet when we came into office, it was the most incarcerated of the big cities. It was the poorest of the big cities. It had the highest level of supervision and parole, 25 times higher rate than New York City when we came in here. And yet it is a majority minority city. And it's also a city that's about 85% democratic. And arguably the poorest and the most violent of the 10 biggest cities, most chronically violent anyway at that time.  How is everything so bad all at the same time? That's when we came in and that was the mission we faced. And part of the mission was trying to figure out how you unravel that, that unique combination of economic failure that seems connected to criminal justice policies that don't make you safer and that tear the city down. That was the mission, it's a big mission. We've made, I think, some significant progress while simultaneously slamming into the pandemic, which has been a challenge all across the country. Some reforms that you implemented coming in that will probably sound pretty good to a libertarian audience such as basically not declining to prosecute marijuana crimes, opioid possession, sex, work type crimes. You know, what what libertarians would call victimless crimes. What were you hoping to achieve with that policy? And how has it panned out so far from your perspective? Was we wanted to increase the focus on the most serious crimes that tear apart society, situations where I believe that we do need to have jails and we need to have incarceration and we need to have consequences. But part of doing that is to stop taking offenses where they are that are either victimless or nonviolent or not serious and try to deal with them through public health approaches. So look for example at sex work or as they call it in the Pennsylvania Code prostitution. You have a situation in which you are to a large extent dealing with women or men because it can be both and sometimes non-binary people who are victims in various different ways. They're struggling with trauma. They're struggling with mental health issues. They're struggling with addiction in many circumstances. And what you're doing by locking them up and putting them in custody and what you're doing by making it so they cannot go to police to protect themselves against people who want to harm them. And what you're doing by giving them convictions is making it harder for them to reintegrate themselves into society when they're able to address these issues and you're not providing them with support for these issues. The reality is you're not getting good drug treatment or mental health treatment or trauma treatment when you're in jail, right?  So no, we're not gonna do that. We're not gonna make it worse for people who we view fundamentally as victims. We need the rest of government, the rest of society to work with us to provide them with some resources. Freedom works better than incarceration in that situation. Similar feelings, of course, about possession of all drugs. While simultaneously wanting to be a catalyst for support. We have seen tremendous success in other countries and Portugal is one in very, very drastically decreasing addiction. Actually in Lisbon, an 80% reduction in the on street persistent use of opioids over 20 plus years by getting away from cops and judges and courthouses by trying to address the underlying needs that led to the drug use in a system invented by a doctor. But Portugal has a far more robust drug treatment system than does Philly. And cops, judges and courthouses are directly involved. Since 2001, the government can force drug users to appear before a panel of doctors, psychologists and social workers who can opt to refer them to treatment and impose a fine for non-compliance. Portugal's reforms in 2001 were more far reaching than the abolition of penalties for using and possessing small quantities of drugs, noted a Swedish researcher who studied the system in 2021. When Portugal decriminalized drugs in 2001, overdose deaths plummeted. But they've climbed back up in the past decade. Without that being present in a place like Philadelphia, does it still work to decriminalize something like opioids where people or even heroin or now fentanyl is what's dominant in the supply? Or does it cause more problems? So let me not overstate where we are. We still accept prosecution of people for possession of these drugs. But we make every effort in the prosecution for possession, which is different than selling. We make every effort to enable them to voluntarily get treatment. And Portugal is very much on the voluntary approach, because the reality is that when you're dealing with addiction, people who are successful in dealing with the addiction often have to try to embrace treatment seven, eight, nine, ten times. So rather than forced treatment, which doesn't work, if you make it available to people who when they are ready to get it, will obtain it, what you find is that all the resources go to the people who are ready. The success rate is much higher and you get benefit from it. Simply by taking all of the resources and money out of trying to criminalize what is, in my view, essentially a disease, what you're doing is you're creating the resources that allow you to provide that treatment. No, it doesn't happen overnight because I ain't the governor, I ain't the mayor, I ain't the legislature. I can't do all of that overnight. But if you never start the process, you will never get to the end. Another major aspect of your reform has been bail, which you came in announcing that you wouldn't seek bail in cases, except in cases where a particularly violent crime had occurred. And the rationale is you're filling up jails with people who haven't even been convicted of a crime. There's one 2016 study that found that up to 30% of jail inmates are there just awaiting trial and it's costly to the taxpayer. It's potentially violating innocent people's rights. The police have said that this has resulted just in like a revolving door where they keep arresting people over and over again and they just keep ending up out there on the streets. So what is your view of how bail reform has gone? Well, let's understand something. I don't set bail. Bail is set by judges. And it's set by judges after they hear from the defense and they hear from the prosecution, which is being skipped when people start saying somehow we're creating a revolving door. We're absolutely not. In fact, we are very dissatisfied in serious cases involving violent crime that the bails that are being imposed are way too low. So it is complicated in that sense. The first thing we did 45 days in in 2018 was we set for nonviolent, low-level misdemeanor offenses where people don't present a danger, we're not going to ask for money. Because when you ask for money and judges put little bits of bail on people, the homeless ones, the broke ones sit in jail, but the ones who have a job get out. And the jail is not for poverty. If you present a true danger to the public, then in my view, you should be in jail pending trial because you present a true danger to the public. No matter how rich you are, money should have nothing to do with it. But on the other hand, I don't want to be holding people in jail for 135 bucks a night because they can't pay $100 when the person who got arrested for the same damn thing but has a job can get out the same day. That doesn't make any sense. What we found after a year of taking 25 different nonviolent, non-serious offenses and not seeking money bail for those offenses was success. We found out there was no increase in crime related to it. There was no increase in people failing to come to court, which is what it's supposed to be for. Freedom really was free in that situation. A separate phase happened during the pandemic when we had the additional exigency of trying to make sure that our jails didn't become super spreaders. Five out of 10 of the super spreaders early in the pandemic were in custody, right? So we now had the way public safety in traditional forms, but also public safety that could flow from the spread of a deadly virus within custody. That got complicated. But what we did there was took an even more adamant step towards, look, we're either going to hold you on a very, very high amount of bail because that's the only way under Pennsylvania law we can hold you because you're that much of a danger or we don't want any money at all. We are going to divorce this process from money. So if you present a real danger to the public, you can sit in jail until you trial. And if you don't, you should get out. And this should not be about money. We made these arguments, but judges set bail. We don't. And what we have found is that things have improved. We have a lower number of these low bails that hold in broke people but let out middle class or rich people. We have a lower number, so that's progress. But we have, and we also have a higher number of high bails for people who, for example, are charged with a shooting which a 16-year-old has hit at a recreation center while people are playing basketball. We have a higher number of those high bails, but are we happy? No. We are frequently seeing a lot of bail commissioners who are used to an old system. It's a system that benefits bail bonds people and it benefits counties. It becomes a trough of money for government. They're much more comfortable with these bails that are kind of in the middle. And that's a problem that we're still working on. The real solution here is legislative, but you've got a legislature now that is so lobbied up and donated up by people who make money off of the bail industry that it's going to take a while. We're going to have to get the people to get us there. You've been criticized by the other side for doing this thing where you request a very high bail of $999,900, $1 under a million bail. And I guess what you're saying is the rationale here is bail should either not be there at all or it should be so high that we just are holding the person. What do you say to the critics coming from the other side that, well, this ultimately has resulted in some people who didn't commit a very serious crime having this insane bail over their heads? I respect their opinion, but I disagree. I mean, the reality is what we are trying to emulate here in a state that's all about the cash bail is what they've been doing in DC for over 30 years, which is we're either going to hold you and it's not about money or we're going to let you out and it's not about money. DC has the advantage of also providing services. So when you have broke people or people who are suffering with addiction issues, mental health issues, homelessness issues, things like that, what they'll do is they won't make you pay any money, but they'll give you resources that you go to from the time of arrest. That's a more positive system than we fund here yet. But I can tell you there's nothing new about this. This approach of divorcing money from whether you're held or not is something that we now see not only in DC for a long time with what I view as successful results, about 88% of people down there get out without paying money. About 12% of people are held for trial because they pose a real danger. We're not seeing it just there. We're seeing it in New Jersey, Kentucky, Illinois. It is spreading throughout the United States. Not immediately, but it is spreading throughout the United States and it's absolutely the direction we should go. We should stop profiteering off of holding people in jail. We should be holding them, if at all, because on the facts that we have, they present a real danger. Philadelphia has seen an alarming violent crime spike over these past couple of years. Both gun homicides and armed robberies have gone way up. And this is different than many other large American cities which did see crime spikes during the pandemic, but have somewhat subsided more so than Philadelphia. And your critics blame you. They say it's these bail policies, first of all, with the so-called revolving door. Also, your unwillingness to prosecute gun crimes, which gun arrests have gone up, but gun prosecutions have gone down. So given these stats, how much blame do you deserve for what's happening in Philadelphia? Well, almost all the stats are just untrue. The reality is we actually charge gun possession cases at a higher rate than the people who came before us. Our conviction rate for homicides, for shootings, for homicides with guns, for rapes, for carjackings, for robberies with guns is extremely high. All of those conviction rates at the trial level are in the 80s and 90% levels. What you're referring to is really a political narrative that serves certain people, but it is not accurate. But I've seen the graph where the gun arrests have gone up, but the prosecutions have not stayed up. So what's going on with that? So that is not what the graph shows. The graph shows that the gun arrests have gone up, but the success with the prosecutions has not gone up. It has gone down in certain instances. What's going on is a combination of factors. One of them is that there are a lot of illegal searches that are done in these cases. And I don't say that to blame anybody, but the reality is there are a lot of illegal searches. So a lot of those searches are thrown out by judges because they're violations of the Fourth Amendment. And we cannot convict people when all the evidence is thrown out. A lot of those are cases where you have a civilian witness who absolutely will not show up no matter what we do. And many of them we have police witnesses who are not showing up repeatedly and those cases are thrown out. There is a fictional line that people like to put out there, which is essentially that if a prosecutor starts a case, then it must be perfect. And if they don't win the case, then obviously it's their fault. But you have made, correct me if I'm wrong, but you have made the decision not to prosecute certain gun possession cases where it doesn't involve an actual violent crime. No, that's not correct. We actually prosecute every single kind of gun possession case. What they may be referring to is for a small number of cases, a few percent, where we have basically law-abiding people who are having, for example, a first offense with a lawfully purchased firearm, but are in violation of not having a piece of paper that says you can carry it on the street. In those situations, we hold them accountable with consequences, including community service, long-term supervision, various other things they need to do, fines and costs, things of that sort, but we give them a pathway to avoid a conviction. And we do that because we believe society will be safer if you take law-abiding people who made a mistake and did something wrong and you don't make them unemployable. Now I can tell you, we've studied the recidivism from that, in other words, the rate at which they then get arrested later. And if we look at the ones we divert and granted we're cherry-picking, we're picking people who we believe are safe, their rate of reoffending is one sixth of the rate of the ones we prosecute. Nobody talks about this, but there needs to be a velvet glove and there needs to be a hammer. When you can tell the difference between the wheat and the chaff and you're taking people who have done something wrong, like buy the gun legally and with good intent, but they haven't gotten the permit to carry, when you can tell the difference between those people and the ones who are out to do harm, then you can make it safer by prosecuting in a different way, which is to hold them accountable with diversion rather than conviction. So do you have an alternative explanation as to why violent crime is setting records in Philadelphia because you can understand how someone would look at the situation and say, okay, this reform DA came in and changed the whole way that the office is run and now these are the predictable results. So what is the alternative explanation for what's going on? Well, first of all, once again, just to get dig in on the data, we looked at where we were a couple of years ago and we'll give you all the data, so you can check it later, make sure I'm not making it up. But my recollection is of the 50 largest cities in the United States, there had been an increase in homicides or homicides by gun that was on average 42%. We were up 40. So the notion that we're somehow leading this mission when we're actually ever so slightly below average is just not true. We're actually somewhere in the middle. When you look more broadly, you look at the history of the city of Philadelphia, the two highest periods of increase in homicides were actually under Republican district attorney quite some time ago and they didn't have to deal with a pandemic. We're dealing with a pandemic. When you look countywide, and I ain't making this up. I know it's hard to believe, but it's real and we got it for you. If you look at the very individuals who are trying to bring about impeachment, what you will find is that during a two year period when we saw homicides go up 59% in Philly, one of these dudes, it went up 800% where he lives. Another one, it went up 400% where he lives. And the other one, it went up, let me make sure I got this right. It was 800, it was 300, and it was 250%. Those are the people saying we need to look at Philly where it's gone up 59% because we're Republicans and we wanna get elected and we're all about the fear. That is what's actually going on here. What we have here is a terrible situation, but it is by no means a leading terrible situation in the United States. Take a bigger look at this and I would encourage you to look at an article which is called the red state murder problem. And what you will see is they did a study in 2020 of what states were the most murderous and what cities were the most murderous. What they found was eight out of 10 of the most murderous cities were Republican cities, essentially Trump cities. And when they then looked at the difference between all the states that voted for Trump, the places where you would expect to have more conservative policies around prosecution and also more availability of guns. So look at all the Trump states, they used Trump, Biden as a proxy for these two different approaches. What you found was that the murder rate in the Trump states was actually 40% higher. And this is all the Trump states compared to all the Biden states, the murder rates were 40% higher. So help me now here, please. But I mean, you're talking about at the state level whereas these, I mean, I can't think of many large cities that are governed by what you would call a Trump Republican. No, I can and I'll give it to you. I have the list and I'll be happy to pull it out. So you're saying eight out of 10. I'm telling you the top city in the United States for the increase in violence is a Trump city, so Trumpy, that they got that prosecutor and had that prosecutor represent the Republican Party in impeachment of Donald Trump. That's what we're talking about. This is a sweepingly false narrative. Krasner is right that eight out of 10 states with the highest murder rate in 2020 voted for Trump and seven of the 10 were governed by Republicans. But violent crime tends to be a more localized problem. Of the 10 big cities with the highest murder rate in 2020, all were governed by Democratic mayors. Krasner has also pointed to three of Pennsylvania's rural counties with a higher percentage uptick in murders than Philly between 2019 and 2021, all of which are represented by his Republican adversaries in the state legislature. But because those counties all had at normally low murder rates in 2019 and their baseline murder rates are so low, their 15 excess murders were more likely to be random statistical noise than the excess 250 murders in Philly over the same time period. That's not to say the murder spike was just a Democratic city problem. Fort Worth, Texas, America's second largest Republican-controlled city also saw a steep jump in homicide between 2019 and 2020 and the largest Republican-led city in America, Jacksonville, Florida, hit its highest murder rate since 2007. But unlike in Philly, murders in Jacksonville and many other American cities have fallen sharply since. 2022 police data shows Philly is close to matching the all-time murder record it set last year. Philly has seen overall violent crime rise by 7%, property crime by more than 30%, and commercial burglary more than 50%, according to police stats. So what we can agree on is that Philadelphia, it set a murder record last year. My question is, if it's not a problem with coming from the DA's office, what do you think needs to change to get that murder rate down in Philadelphia? Or is it not a policy issue? No, I think there's a lot of things that have to change in Philly. First of all, in Philly, you're dealing with the poorest of the 10 largest cities. There's no question that there is a heavy correlation between poverty and economic failure, particularly on a neighborhood-by-neighborhood basis and chronic violence. Philadelphia has been a chronically violent city for decades. What has been done through traditional, lock them up and hang them high approaches has never worked to reduce violence in Philadelphia. That's where it has been. So what works? Two things work. One is modern enforcement, and that includes things like some pretty amazing forensics that are now available that have been available but have not been funded. It ain't good politics to fund forensics. It's good politics to fund compensation for large police unions that wield political power like some other unions. It's good politics for police not to be accountable because then their leadership endorses the right politician. But it's never been good politics to put the $50 million that Philadelphia needs into a forensics lab that would allow them to go from the statistic they had a few years ago, solving 17% of shootings to solving 30% or 40%. That would make a huge difference in deterrence. So that is part of modern enforcement. It's other things like more wiretaps. Mobile wiretaps obviously supported by probable cause. It's other things like camera technology and things of that nature. And a society where you have almost no witnesses in many of these cases because the bonds between law enforcement meaning prosecutors and police and communities are so broken. So there's a modern enforcement side to this that is super important. But the other side of it is a frankly never before serious investment in prevention. And that takes many, many different forms. If you view the most sacred obligation of a prosecutor's office or law enforcement to try to prevent the next victimization, that is really a much better goal than to give somebody a life sentence after that person has taken a life. It really doesn't do that much. But that prevention money gotta come from somewhere.  We put that money into prisons. We put it into jails. When you look at the decline of money available for education for poor people especially public education, it coincides very neatly with the growth of everything that was about locking you up and throwing away the key. We have to get these resources from somewhere. And when you look at economic decline in areas where they've been all too eager to give you a permanent conviction for turnstile jumping or a first retail theft or something like that. What you see is employers don't wanna go there because they don't wanna hire people who have prior convictions. So they locate their businesses elsewhere. I think you see my point. What you see is that much of this is very, very counterproductive. And the answers have to be the lessons we got from the pandemic.  When you had those things going on, you had much lower levels of gun violence. And when they went away, we saw this incredible spike. When you give young people a sense of hope, when you give them constructive people to do cause it is young people killing young people for the most part. When you do that, you start to see these things go in a better direction. You mentioned lowering sentences for like retail theft and things like that as being part of the solution. And that was something I wanted to talk to you about because this is an issue that's become something, this was an issue in San Francisco where people complained a lot about quality of life type crimes where the shoplifting went way up, they say, because of decreased penalties for shoplifting. And you've made it a policy, to have kind of a summary judgment or not summary judgment, what do you call it? Summary offense. Yeah, a summary offense for people, $500 or less, you know, you've lowered probationary periods. A summary offense, by the way, usually is like a fine or at most no jail time. So, and then some of that same police data I referenced earlier showed that infiliate property crimes up 30%, commercial burglaries 50%, do you think that that has worked out in a way that has made quality of life worse here in Philadelphia? No, the reality here is a lot more interesting and a lot more complex. We are seeing a big increase in property crimes right now, but if you look at the last two years, there was a big decrease in property crimes. When you lock people up in their homes and you shut down businesses and you have them sitting near their car all day, what you're going to see and what we did see was in many, many, many categories very significant declines in property crimes when society came back online as we saw the diminishment or the diminution of the pandemic, people started to go back to work. We saw these spikes going back up. This is also, of course, happening in a time of tremendous economic displacement. We have a voracious, arguably out of control situation going on with opioids that feeds much of this. So no, I mean, a lot of that simplistic, it's not even true that we're punishing people less for retail theft. The reality is that I was in the system for 30 years as a defense attorney in one way or another. They used to charge higher levels of the offense. They charge a misdemeanor every now and then a felony, but very few of those people ever went to jail and with the summer, you can go to jail for 90 days. What it does is it takes people out of this ridiculous process of tying up police, handcuffing people, taking them to a police station, keeping them in jail until they pay bail, which a lot of times they cannot pay bail, then they go to court, then the witnesses don't show up anyway in very, very high levels because their employers don't want security guards to be in court. They want security guards to be at the store, all right? So a lot of this is really just, it's just, that's what it is. You're facing impeachment now from a Republican-led state legislature, although some Democrats have joined them in holding you in contempt for not turning over some materials related to a case that you say, you can't turn over because it's grand jury material. Because it's a crime, yeah. I don't like me to commit a crime. You've called this whole... I'm declining to do that. You've called this whole thing illegitimate. Why is the impeachment proceeding illegitimate in your mind? So the reason it's illegitimate is you impeach people for committing crimes. You impeach them for deep, deep corruption. This is a legislature that has almost never done it. It has never happened in the history of the Commonwealth, which is hundreds of years that they have said we're gonna impeach somebody not because that person committed any crime, but because we disagree with their ideas. Understand where this impeachment is coming from. I was elected the first time, handily, the second time with an overwhelming landslide. We got 72% of the vote in Philly. We got more than two-thirds of every Democrat in the primary. And in the areas most affected by gun violence, the ones where if you bought any of this nonsense, you would think they'd be against me, I had the highest rates of support. We had rates of support that were 80 to 85% in the areas most affected by gun violence. That's what Philadelphia thinks about the person they freely and fairly elected. People leading this are from hundreds of miles away. They do not live in Philadelphia. They're not permitted to vote in Philadelphia. They're from Beaver County. I did not make that name up. They're from Washington County and Adams County. They're from these far away counties that are rural, that are to put it mildly gun-loving in ways that we are not. We have some ideas about reasonable regulation of guns. They don't want to appreciate it and neither does their financial sponsor, the NRA appreciate. But their point is we may not live there. We can't even vote there. But our few votes out here as legislature should allow us to remove you because we don't like your ideas. That is the end of democracy. That is the gutting of democracy. It means that anytime you have a dominant party, they can remove the opposing party by saying we don't like your ideas even if your constituents love them. That's where we are. And no, it's not a surprise that we are less than one month away from a hotly contested midterm election where one party has a very large contingent, shall I put it, of people who are either insurrectionists themselves or their election deniers or they are essentially patronizing and supporting insurrectionists. You were elected here before the killing of George Floyd which really brought this issue of criminal justice reform and police reform to the forefront of a lot of people's minds. But you, that did sweep in a lot of other like-minded prosecutors around the country, Gascon in LA, Chesa Boudin in San Francisco. There's this public appetite for criminal justice reform. You, as you mentioned, won your reelection quite handily. You, there was significant backing from progressive activists like George Soros which conservatives like to point out. I mean, not really the second time, but. He backed out the second time. First of all, he never supported me directly, but there's your pack. No, he never gave me a dime in my pack. He was, well, anyway. Or two-a-pack. I don't want to be weighing into the weeds with this, but the fact is there was significant outside support over a million bucks. Put into TV ads and radio ads by people I never met, never conferred with, with whom we never did anything, right? That happened the first time. There's no question that amplified our message the first time. The second time, there was almost none of that money. It was, I think less than $200,000 or something like that. Represented only a few percent of the entire amount. It was once again, all on the outside. And that was very simply because we were running off of our deeds instead of our ideas. People in Philly knew what we did and they wanted us. Our donors actually, on average, donated far less than my opponent. Because the point I was trying to make is that there was this large, there's this enthusiasm and money and support for this cause. And now it seems that there has been some backlash. I mean, Boudin was recalled in San Francisco. Gascon has survived, I think, a couple recall attempts. And of course, you're now facing impeachment here. What do you predict for the immediate future of the reform prosecutor movement and let's just say criminal justice reform more broadly? Success. And let me tell you why. So if you look about two and a half, three years ago, we had gone from zero progressive or reform prosecutors in the United States to the point where 10% of the US population lived in those jurisdictions, 10%. Around George Floyd in a two-year period, that amount increased to about 20% of the US population. You're talking 70 to 75 million people. There is no political group, political party in the US can say we doubled in two years like that. And their influence was even bigger because many but not all were big jurisdictions. So 20% of the population really was involved with 30% of all criminal cases. This is a problem for people who are opposed to what we are doing.  First, Kim Foxx didn't work, then they tried to stop George Gascon who by the way was a career cop and a career police chief before he became the DA in San Francisco for six years, which is what he was. He is one of the earliest of the progressive prosecutors and he is the copyist of the progressive prosecutors.  He then does the unthinkable and gets elected beating an incumbent in the largest criminal justice jurisdiction in the United States. Yes, they came at him twice with recall efforts in a state that needs to change his stupid recall laws. They failed twice, he's not failing. You look at Chesa and I say this as someone whose son lives in San Francisco where last year the average sale price for a home was $1.8 million, okay? It's a special place. It ain't Baltimore, it ain't St. Louis and it ain't Philly where the average home price here is probably on the order of about, I would say a quarter of a million bucks, which is a price, but it's not 1.8. What actually happened there is Chesa lost and what's happening in Oakland, which is a bigger jurisdiction right across the water, you're about to see Pamela Price win as the progressive prosecutor there when she couldn't win four years ago. What happened South of San Francisco in other big jurisdictions. You saw the reelection of Diana Bekton who's a progressive prosecutor in one of those counties. What we are seeing now and I'm giving it to you as straight and objective as we can is that in a time of tremendous fear, when people who are conservative and are carceral and believe in a carceral state, they want this country to be more incarcerated than Vladimir Putin's Russia feel like to have a moment because there is real concern about crime and there should be. There is a surge in violent crime and it's real. Those same people are trying to run a fear-based kind of politics that is not scientific, is not based on data, it doesn't look at causation, it doesn't look at solutions. They're trying to run that crap again just like they did in 1968, but even in that hostile climate, and I ran for reelection in that hostile climate, I ran last year, even in that hostile climate, what we're seeing is that the progressive prosecutors are getting elected and they are getting reelected, they are at least holding their own at this time, but the tactics have changed. What we're seeing is that the opponents have almost given up on elections because they know that they're failing when they try to get us out with elections. What they are doing is they are resorting to anti-democratic tactics that occur in between elections. They're either taking away people's authority to make certain kinds of decisions unlike all of their prosecutor colleagues, unlike decades of tradition, or they're trying to do recalls, or they're trying to do impeachment under brand new theories. The brand new theory being here, being I can impeach you for your ideas, I can impeach you for your policies, really? Can we? You better hope you don't have Democrats in charge of the state who are as cynical as you are because a whole lot of you are gonna be out of work and we might as well give up on elections at that point. So what you're actually seeing is that these tactics, like all these recalls and impeachments, reflect that they can't beat us at elections and they can't even beat us at elections in any significant way in one of the most frightening times with some of the worst crime that we have seen. So given that you're optimistic that the Reform DA is going to survive all this, are you also optimistic that the project of working towards a society that is not the most carceral country in the world will succeed over in the coming years? I'm optimistic, but we have, I mean, we gotta be honest about our history. Our history, unfortunately, you know, if you would look to like the writings of somebody like Brian Stevenson, he would argue that we didn't actually eliminate slavery, we it morphed. It went from a strictly slave system to a system of mass incarceration. You know, we see tremendous successes in the history of the United States, in my opinion, things like the election of Barack Obama and then you have the insanity of the election of somebody like Donald Trump who I wouldn't actually let sell me a pair of shoes. You know, we have that kind of stuff going on. So the part of me that knows how many people in this country are people of goodwill and resort to reason they believe in history and science and truth, that part of me is very optimistic, but we cannot deny the reality that there is a contingent in the United States who are fundamentally racist, who are either unscientific or anti-scientific, who do not care for democracy and probably never did and who do not care for truth. What exacerbates it? We could talk about that all day. How we got here, we could talk about that all day. But certainly what we have here are two profoundly divided and competing forces. And I intend to spend whatever energy and time I have supporting science, truth, history, data, things that work, solutions that are new, where we have failed and trying to fix things that have been wrong for a very, very long time with solutions that don't look like some evolution of slavery. Larry Kressner, thank you very much for talking to reason. It's always good to talk about slavery is bad and it's libertarian, so it's been a pleasure.


All right, so why re why react so we're gonna a quick little kind of about react So it makes building you eyes easy. That's kind of stolen from their there's their Website and it's a personal and unopinionated library So some of the benefits so what makes it easy is you have this thing called JSX Which is something that people either love or hate or grow to love It has a virtual DOM which it uses for performance reasons And it's it's one of the magic things that happens under the hood that makes react Possibility and it has a really small API and so that's going to come key in this Coding that we're going to do because again, I really don't have a whole lot to show you because there's only like a limit Like react itself is very limited in its part Some of the other benefits is it has a vibrant ecosystem. So there's almost a component for pre-medge anything you'd ever want You could find a component like you need a video player if you need a background video If you need any of this stuff if you need Facebook sharing buttons social sharing buttons Like these things all exist and you just pull them in as components and use them It has a community that's building and improving and experimenting. So this is to me. This is something that I really like I like that the react community is constantly trying to make what they do better or trying to Challenge the way that they do things now to find even better ways to do stuff And and we're getting to a point now where we have some proven But maybe still evolving patterns and in the advanced react course We're going to talk about some of those patterns, but over time now we've had react long enough that we started to kind of get an idea of Where are some of the ways you can build components? What are some ways you can structure your application? And there's a lot of best practices that we can rely on because the community is constantly Trying and making things better So some of the learning curve steep learning curve. So if you'll notice here my drawbacks are almost exactly my benefits So I love that it has a small apion is really you know What it does is very simple But that's actually kind of a drawback because it really means that you have to understand JavaScript and you have to fill in a Lot of blanks when you're writing a JavaScript application it again It's just a view layer essentially and it only handles a small part of an entire application. It's very different from something like Like Meteor or angular where it's this entire framework and it has pretty much all the all the problems and all the solutions Figured out for a complete application But yeah, it leaves a lot for you to do and the ecosystem so the ecosystem I love the fact that we're experimenting coming out with new stuff really challenging the norms that we have But to some people that can get old really quick and so I think that's another kind of a love hate kind of thing within the community one of the cool things at least I think it's cool is React has really pushed forward this functional programming kind of concept in JavaScript JavaScript is always really lended itself to being a functional or being written in a functional way and React really start is really what introduced a lot of people to this kind of functional paradigm And you're gonna kind of see some of that As we go through and start coding So one of the things that you'll hear when people start talking about react and functional programming is embracing a declarative versus imperative style of programming So At a high level what you'll hear is on declarative is what should this page look like so when you write stuff in a declarative way You're really saying this is what this should look like and you really don't get yourself involved too much in the details So if you were in the first talk that I gave where I did the higher order component or functions and I did map filter and reduce Traditionally if you wanted to do those things you would have done a for loop and you would have to set a variable and you Would have to increment the variable and all this you're doing all this busy work to make it loop an array so that would be an imperative whereas Using map filter reduces more of a declarative. You're not really telling it how to loop You're just saying hey when you loop do this, you know So that's kind of the difference between a parative and declarative programming And you'll see this in react as well. So the app that we're going to build it's a small little app I have a vanilla JavaScript version that I'm gonna show you first And we're gonna kind of look at the code and then we're gonna Replicate that in react and you'll kind of see that the vanilla JavaScript version is much more imperative than declarative And I always like to say that and I don't know if I stole this or if this was I may have stole this I don't know but the page is a visual representation of the data Which is once you get that into your head and you really start to think about thinking about At the end of day It's just data and all your all your view is is a visual representation of that data So if the data changes your view changes and you only have to do a little bit of work to make those changes happen Once that starts to click you'll really start to see the power that is react All right, so these are some links that you can follow to so I'm going to be using a thing called code sandbox today It's a it's a way for us to code react view vanilla JavaScript They have you can code in anything you want For JavaScript and it has an editor and has live reloading all this cool stuff That way that's what we're going to utilize today when we're doing the live coding So if you go to the first link code sandbox, you're going to see a list of all kinds of sandboxes that I've created Some of them were the jQuery from before What we're going to build today will be on there once it's completed right now. It's empty And there are some other ones for the other talks and just some some really cool sandboxes that could be useful To look at because what you're going to want to do with all of this stuff Once you see me kind of build it out is you're really going to want to get in there Get your hands dirty start breaking stuff moving stuff around and really trying to understand how it works And I think it's really cool that you're going to be able to take something I make and just start to use it and what's also really cool about it Is that we don't have to worry about installing any type of third-party packages or worrying about it Whether you have node or npm or any of these things installed on your local computer you can get coding right away Now specifically we're going to go to the intro to react example That's going to be the one that we're going to be coding right now I'm not set down for this All right, so here's the vanilla JavaScript version of what we're going to build It's it's kind of a to-do app except you can't check stuff off all you can do is delete stuff so it's it's Correct we're going to code that out here in a second. That's where I need your that's where I need your prayers and wishes that It really goes well because it's an empty file Thank you Okay, so here is the here's here's a vanilla example of what we do are what we're going to build So pretty much you can add to do's and you can remove them and that's really all this thing does All right, so you can just add stuff So let's look kind of look at the code So if we go down to line six here This register to-do list what you'll see is I've defined a function and Then afterwards I initialize that function so this is just kind of a pattern I use when I'm writing vanilla JavaScript and So what generally happens is is this code would be in a separate file within my project And I'll export this register to-do function and then in my index.js Which is like the root of my entire project I'll be pulling all of these little files in using the imports and exports from the previous class So what I'll do is I'll have a file I'll define this function Export it and then an index.js. I'll import it and then I'll call it and Other than just kind of separating your code and making it easier to kind of figure out where things are One of the things I like to do with or one of the reasons I like to do this with a function is that I can go and get like the core element that I need for whatever it is I'm building generally whenever you're coding something there's like a root element that you need or if you don't have that It's not going to work and I like to just do this bail early kind of concept where The function will go try and find that element and if it doesn't find it It just returns false or returns and gets out of there and it never executes the rest of this code and this is really useful when you're working with traditional websites and vanilla JavaScript where Certain functionality and elements may only exist on certain pages with this kind of approach You don't have to worry about well. What page am I on and does you know? Does this thing exist?  I'm getting this input field and I'm getting this button So I'm using vanilla JavaScript to go and query the document and find those Then the next thing I do is I do button and I do add event listener So this is how you would you know register an event. It's a click event. I get an event I prevent the default and the reason I do that is because if you click the button net Traditionally, it's just going to reload the page Then what I do is I create an item and so the way that I'm doing this here is like I call these poor poor man's templates So I use template literals, which is a new ES six kind of thing where I can say here's the HTML of this item And then I'm going to insert the text of the item And then I have to do this weird thing where I use these fragments and kind of convert this string into actual HTML So that down here this actually ends up being a node element an actual HTML element and I can call a pin child Otherwise if I didn't tell it to do that it would give me an error saying that item is not an node element And then I have to go and remind it to go put the input field back to empty So that it is ready for the next item that I input And then to remove the stuff I'm gonna I'm gonna listen to the on the unordered list I'm gonna listen to any click events on it And then I'm gonna check right here to see if the event Target tag name equals button because that means they actually click the button Because since I'm registering this event on the entire UL anytime they click on the UL and Li a button Any of those all fire this event and I only ever want to call this removing logic When I'm when it's actually clicked on a button So once I know I'm someone clicked on a button the button that got clicked is what's called He is what's in event that target and I use you know JavaScript closest to move up the tree to find its closest parent Li And that's that's how I know which Li I need to remove Based on which button gets clicked and then I call list out remove child to remove that element So again, it's I'm very much in the weeds here telling it step-by-step how to do every single thing Throughout the whole entire application now granted It's not a lot of code and I believe when we do the react version it it'll it's more code overall, but I think Logically and mentally it'll be easier over time as you get more comfortable using react It'll make more sense and it'll be easier to reason about your application Then here here you have a do a lot of reading of code to really understand what's going on with react It'll become easier to really kind of at a glance know what's going on All right, so let's get started So at the end of the day what react is doing is it has it's going to be you're gonna be creating components But at what happens is is those components eventually get converted into creating HTML via JavaScript and beyond and believe it or not You can already create HTML via JavaScript if you want So that's where we're going to start the first thing we're going to do is show you how you could create some HTML with JavaScript Weave them without react and then we're going to start to slowly move our way into the world of react So if we look at the HTML file that gets loaded for this site You'll see that there is a div with an ID of root and that's really all that's in here And that's how a reactor works So react is injecting the entire contents of your application into this one div And we're going to do the same thing right now even with vanilla JavaScript All right, so the first thing I need to do is go get that root element And then what I need to do is I need to create a new element and the element that I want to create is an h1 So I'm using document dot create element. So this is a method that's built on to the document Object in JavaScript, and then I'm going to add a bunch of stuff to it. So I'm going to add a class I'm going to add us some styles And then most importantly, I'm going to tell this element what is in it Using inner text and then I'll take the root element that we found that ID that div that's on the page And we're going to do a pen child and we're going to pass it the element and there you go You can see I've rendered an h1 on the page. It's text-aligned centered. It has a font size And I did that all just with vanilla JavaScript and you can see if we do the console down here You can see that the div with the idea of root now has an h1 in it And it has a class of YOLO and it has some inline styling added to it So again, the whole the whole what JavaScript does is it allows you to build an entire application including h2p on everything in Purely JavaScript what you'll notice here though is that who wants to do this? I mean This is ridiculous So let's let's try to do it with react now what we're going to do first though is we're going to use Kind of a low-level API that's built in the react that you're not actually going to use But I just want to show you that there's this kind of wrapper around what we've seen here That's in react and so we're gonna do that now So I need an import react for this to work I want to cool things about code sandbox is that it's already pulling these dependencies in and it has a build So it's running babble It has things like ES lint for linting and you're gonna see a lot of these errors coming up and they're they're kind of helpful So I just want to point out that there's an entire build application here There's all kinds of stuff going on that we don't have to worry about and so that's why I'm able to just go Head and start importing react without actually, you know setting up a project So similar to the document, we're gonna give it what we want it to be Then we're gonna give it an empty object for now And then we're gonna tell it what the text or what should be in it what its children should be and then in react We have another thing called React DOM so in the way react is built is that the core library of react is in a react package And then the stuff that has to do with the web is in a package called react DOM And then later today when we do the native stuff, you'll see that there's another packet called react native So you have this DOM and native packages and they all kind of pull from the core react So whenever you're working with react not only do you know we have to pull react in but you also have to pull in This other thing and for us, it's the DOM And so what we're gonna pull in is we're gonna pull in a method called render That's in that react DOM package And again these packages are in my node modules if you could see my node modules So these are packages that were installed Using your modern JavaScript, and so that's why I have access to them So I'm gonna use this render and what you do is you pass it The root and then the element I think or maybe it's the other way around and so now you can see that I have a hello world Now this this object that it gets passed You can actually do a lot of stuff with this and one of the things you can do is pass all the props And you're gonna learn about props in a minute and one of the things that we can pass though as a style Object and then we can do this kind of the same stuff we did before And you'll see now we kind of have pretty much the same thing that we had using the vanilla JavaScript And again, this right here is what's called the children so one of the things I could do is I can make another component and a copy a lot of this This one's going to be a div worry about this stuff and what it's going to is it's actually going to get the element As a child and then we're gonna render it out So again, nothing has really changed visually But if we inspect this we'll see that we have our root element that we had before and now we have that new div Which is the wrapper and then we have our h1 inside of it So this is kind of how under the hood react is converting your components into something very similar to vanilla JavaScript It's just just a little bit better And that's the big takeaway here is that no one's we still don't want to do this this sounds horrible All right, so what we want to do now is we actually want to start to use Reacts component Classes to build out our components the way you normally would in react and so let's let's convert what we have here to work with that I love that it saves right away. That is so awesome All right, so we're going to create an app component So this is what's so this first kind of component you're going to see this is what's called a functional or stateless Component so this is a component that's really built out as a function So you can see this is all this really is is an arrow function from the modern JavaScript So this is the first and simplest way to create a component And it's the way that you're going to want to try and create as many components as you can Because they're also referred to as dumb components because they literally take some data and they represent that data as HTML And that's all they do is take data and represent it And it'll make more sense in a minute But let's just go ahead and make this do something All right, so that's our first component. It's I think it's going to be It's going to win a lot of awards for sure But yeah, so you can see all I've really done is to find a function and the reason this works is because I have react on the page And this right here is your first introduction to what's called JSX So this is not HTML. It's a it's a parser and kind of like a language in and of itself That's packaged into work or react. It's not even part of react. It's its own thing But what react does is it uses it to parse this and turn it into Those other create elements that you saw before so that's what it's doing under the hood is it's converting this JSX into those create elements and rendering it all into the page and Once you've created a component to create to actually show off or to use the component you use you use this syntax right here Which also looks a bit like, you know closing HTML and again this render is just injecting this entire component into that root ID And what and you can do things like styles so We can pass this an object So and when you're doing JSX you're going to do stuff like this and we're going to do this kind of thing with props But for right now we're just using style so style equals and then you do square brackets and Then our curly braces and then inside of those curly braces You want to give it an object that represents what you want so similar to what we did a minute ago Right, so we're just passing in that that's that one so and when you see you when I save there that so that's another thing called prettier I don't know if you are using prettier with your coding prettier simple essentially just format your code And it's really nice, and it's really made me a very I mean I think developers are lazy anyway But it makes it to where I just write whatever and hit save and it makes it look good, right? So if you're into laziness Get prettier Also, too if you're using ESLint ESLint's gonna yell at you and throw you lots of errors lots of really useful stuff It's gonna help you catch a lot of things that probably would have been errors at runtime when you loaded the page And if you just have ESLint in there by itself You're going to you're going to be hating life because it's gonna be yelling at you all the time for every little thing But when you use ESLint with prettier so long as you're using similar styling patterns because you can kind of mix match You can change the styling a bit When you use prettier than ESLint together what's nice about that is prettier fixes 99% of the stuff that ESLint would have yelled at you about doing and it really only leaves ESLint to show you stuff That's really important All right, so now what we're going to do is we're going to but we're going to create a new component So we're going to start to actually implement our vanilla JavaScript thing that I showed you So the first thing we're going to do is we're going to create a component called list item And it's going to be a stateless functional component, and we're going to export We're going to use export default So like this is going to be the only thing that really gets exported from this file So again, this is using a lot of the ES6 stuff and the modern JavaScript from the previous talk and Then we just want to return a list item And we're going to use square or curly braces to inject in the text for this item And this text is going to come via what's called props, and so we're going to talk about props And just a second So this is our first component and it just renders out an ally. That's all it's going to do So we're going to go back over into our app. I'm going to get rid of this And we're going to import this new component list item from Dot slash list item so again using kind of imports and exports So you'll see the difference here is that when I'm importing react and I'm importing render I just call the names directly and it works and that's because by default the import stuff That's built into modern JS knows to go look in node modules for those whereas my own stuff I'll do I have to actually map it to the path to where it's actually at And since this file is in the exact same, you know, same level as the current file I can just do dot forward slash and it'll pull it in All right Now the next thing we're going to do is we're going to convert this app component to be a stateful class based component So this is the second way that you can create a component So we're going to say class app Extends Component And we actually have to import another thing we have to import component We need to have a render method. That's an important. That's a requirement for a class based component And so there you go so now I've refactored that component from a Functional component to a class based component and really the only thing that changed was that instead of it being a function We're now extending a component class and instead of just returning JSX We have to have a render method which then returns that JSX. So those are two main differences At this point there's a there's gonna be more differences and we're gonna be exposed to those as we keep building All right, so the so now what I want to do is I'm I'm going to initialize an initial state for this component This is another thing that makes class based components different than the stateless functional components Components like this cannot have any internal state Whereas these these can have their own internal state And I'm gonna set a data property If right now I'm just gonna make this Just a list of stuff And then I'm gonna switch up what I'm returning here and I'm gonna return a UL And then I'm gonna create a new I'm gonna create a new function or method on this class and it's gonna call be called render So we call it render list items And then I'm gonna do what's called object destructuring I think So bad with names, but essentially I'm gonna this state object This is this is an object right this state thing is an object and I can reference it within react using this dot state But just because I want to be too cool for school I'm gonna do this and I'm gonna say data Equals this dot state so this is something you would have seen in the previous talk where I'm going to essentially pull this out of this Dot state so out of the state and now I have this new variable inside of this function called data Which is literally this that's what I did and then what I'm gonna do is I'm gonna return from this thing And I'm gonna map over the data so I'm gonna loop over that data So this is something again higher order functions from the first talk in I'm gonna use an arrow function from the second talk so I'm gonna get an item and I'm gonna output a list item So we got some work to do here, but I'm we pulled that component We made in this one over here and now we're going to loop over this array of data and for each item in the array We're going to create and an instance of this component and we're going to pass this text in So the item And if we look over here, you can see that I'm I'm destructuring or Pulling this text thing out of the props that get passed. So what we're doing right here is passing props So this right here what you see here is me passing props and the beauty with props is that this name text? That's just what I called it It could have been anything I wanted and it's up to your imagination props can be anything you want and you can pass anything You want is props to the to any of your components that you create and in this instance? I'm clear. I'm passing a Text prop which is one of these items and so over here.  So one of the things I'd like to point out here, too Is that what I'm doing here? There's probably a lot simpler ways I could have even simplified this even more But I actually made the conscious decision to really show you how I actually would write react because unfortunately Most people in react won't be too cool for school and if you look at any documentation This is what you're going to see and so it's very important I think for you to just get get into doing this stuff now So the last thing we need this is kind of a react kind of thing is that anytime you're looping over a list of stuff And you're mapping things like this. You have to pass it a key And it needs to be something unique So normally like in WordPress we would use probably like the post ID But I don't really have that right now. So I'm just going to use the index which is not preferred, but it'll work So what's cool about map? I didn't cover this previously is that not only do you really get the item? But you also get the index. It's just if you wanted to use that or not. It's up to you then lastly We're going to use this function we called we made cool, so Again, the render here is an unord list and then we use these curly braces to build to run JavaScript So in the render whenever you want to run JavaScript you'll use curly braces and so all I'm doing here is I'm running this function Again, this function goes and gets the state maps over the state and outputs a list item for each one of the items here So I have a script. I'm just looking at it All right So I think that this point what I'm going to do is I'm going to refactor this ability a little bit So instead of having all of this logic kind of in our app I'm going to move this out into a separate component called list and again It's going to be it's still going to be a stateful component. So I'll say class list extends component It's going to have a render it's going to return something And what it's going to return is it's going to return the same thing this was and we're also going to just move this part right here over and One of the things that we need to change is that the data is still going to live up here And this is going to make a little more sense here and a little bit why the data is still up in this upper parent component But the data is going to stay up here So what we need to do in our list is instead of getting data from this that state because it was internal to the state It's going to get it as props. So if we just change this to props It'll start to get it from props and it's also going to need this list item because that's it's now the component That's rendering the list item and then we're just going to import list from list and then down here past data and It's also helpful if you export this thing so that you can actually access it There we go. So I wrote a whole bunch of code and we did nothing so congratulations That's refactoring and so and this is something I think a lot of developers do right you take baby steps You make little incremental improvements. So we refactored it out so that it's in a separate Separate place and so now what we want to do is we're going to add more to this So we're going to create a div and inside of that div We're going to render out our list item. So again, nothing's really changed except now this stuff's in a in a div and the reason we're doing that is because we're going to create a form now and Newer versions of react you don't have to you don't have to have you don't have to wrap You can't and in react in the older versions of react You couldn't have an h1 and h2 or two p tags on the same level as each other without a wrapping parent element and newer versions of react that's going away, but Currently code sandbox. That's it still is using that so I have to ensure that I wrap I Can't I can't have a list in a form here. I'll have to wrap them with a div or else it wouldn't work So we're going to create a form We're going to create an input and we're going to create a button There we go. I was getting a little worried there for a second. We're going to code nothing showed up Cool, so I have a form I can type stuff in here and that works And if I hit add you'll see that just reloads page because that's kind of the default action for a form field Okay, cool. So we're actually going to start to do a lot of stuff that has to do with react We're going to start to really learn a lot of Right now with adding it to do we're going to learn how to do a whole bunch of stuff That's really vital to understanding react So one of the things we need to do is We're going to do an on-click event So in react when you're in your JSX you can just type something like that on click equals square brackets And then give it a function to run and so we're going to create a function called this dot handle add item Curly brackets. I keep saying square brackets. So sorry So we're going to create this function And it's going to get an event just like just like if you are registering DOM events with jQuery or vanilla JavaScript This on-click event whenever someone clicks is going to fire this function is going to pass this in the event So I'm going to say event that prevent console log Yolo and you can see it's working And I'm not going to lie when I'm coding I always do this even though I've registered a million events before I got get in there and really start writing all kinds of logic and not working And then I get mad at myself It's always nice to just make sure that at least we'll show something before you get into doing more So what we want to do now is we actually want to be able to get the value that's in the input And we want to do what's called set state. We want to add an item to this array in the state And there's a couple of ways to do this in react But the preferred way that they want you to work with input fields is to make it what's called a controlled component And what that means is is that we it wants us to register an on change event on the input and listen for every key Stroke that happens and then update a value that's in our state But that didn't make sense it will here in a second So we're gonna make a new value in our state called input value and make it set to empty an empty Thing and then down here. I'm gonna say value equals this dot state input Value now, I think it should be still works There we go now you see when I type now it doesn't work So I broke it but that's kind of what we want. So what we want now is that we want these things to happen on change And we want these to be in our state. So we're gonna create a new function called handle input change and I'm just making up these names by the way and It's gonna get an event and we're gonna use something in react called set state So this dot set state and I'll explain this in just a second. All right, so you can see I can type again So what's happening here is that every time I a keystroke happens this on change function fires Which runs our function and it gives us the event an event that target This is just like vanilla JavaScript So this is again kind of like where you really need to know JavaScript on any event event that target is the element That had the event listener So in our case event that target is the input and the input has a value and we can get that value So every keystroke we're getting a value. So like right this second value was ff. Okay, then we're gonna use Part of the react api. This is a this is like one of the most important parts is like is this that set state So set state is how you handle updating this internal state and react And by doing this react is going to do all of the things that you hear about with a virtual DOM and diffing and figuring out What's going on and it's going to know how to render and what to render and what needs to get updated So by setting by doing this that set state. We're slowly changing this value like this, right? And you can see that I actually updated over here. You see that so again Just another little example of your your view is a visual representation your data My data has an input value with all these weird letters and now this thing does too and as I change them over here They change them over there, right? So they're now because we've done this our input value is now being stored what we type and what that means is down here And add item we can we can do this dot state as well It's just that set state And here we can say data equals something and here I'm going to do the destructuring again So here I can say that data equals data dot concat Which is an array method I'm just going to put input value Into an array and kind of push it into the array It's kind of a way I cheat I guess and then an input value I'm going to set back to the empty string So let's see if this works So you can see that I want to add it update step So just again the input is using it on change Which is setting the input values value and then whenever you hit the button on click it runs this handle add item And that's going to get an event And then what we can do there is we can then set state and we can push a new item into this data array So we're pushing our new item wherever you type into this array And then we can also then reset this input value back to empty string so that it's empty and ready for the next thing So if I refresh the page, they'll go away yeah, and Later on today when we get into much more advanced stuff We normally won't actually have a data thing set will be fetching it from like an API or something So this is more for instructional purposes. But yeah, if you just reset it kind of loses its state And then it'll start building the state up again So the state's only as good as the browser that it's in and as soon as that browser goes away or refresh as it clears state It starts to fresh again. All right, so now we're going to build the move functionality The remove functionality is a little bit more complicated. I'm not going to lie and it's going to start to show kind of One of the potential issues you can have with react as it starts to get bigger and your application starts to grow So the first thing I need to do is I need to make a button so you can see now that each of these things have a button and What I have to do is I'm going to have to what we want to do is On the button we want to do on click We want to run a function right and that function is going to go and update the data the state The problem is is that our state is up here in our in our main app component So the way our react app is working right now is we have our main app component Then we have a list component and then inside of that list component We have the list items and the list items is where the actual click event is going to happen from So what we have to do right now is we actually have to pass a function down as props multiple layer levels So you're going to see me doing this right now where I'm going to be passing this this function down as props and we'll get it to work One thing I didn't mention to that's really important So you can see here when I'm creating these functions how I am using Arrow functions right here So the reason I'm doing that is because by default that that does a binding of what's called this is that if you've ever had trouble with JavaScript and this That's why it's because you're working with events in that event This is different from the original this from where you thought the function was going to be If you don't care about any of that just do arrow functions and you don't have to worry about it This will just always work. Okay, so that's the big takeaway and that's why I'm making these all arrow functions Because if I didn't make these arrow functions, this call to this dot set state would give me an error Okay, so the list right here is going to get a new prop. I'm gonna call it on remove and I'm gonna pass it the this handle Remove item function and then I need to go into my list and I need to tell it that it's getting on remove Prop and then I need to take this on remove prop and I need to pass it down to my list item component It's confusing.  Yes, there was no problem All right, that's tedious needless to say but it's manageable especially for quite a while within an application So you can get really far with set state and having and having what are called these container components So our app right now as a container component It contains a lot of the logic it contains the data and then we have a lot of these like you know Not very smart components that really just handle rendering information and what you're going to want to do is in your application You're going to want to do that and you're going to have a couple of these So like you have a main app and then you might have like two container components to have some logic about say like this To do might be like one container that does something and say on the app We had another feature that did something else that would have its container and its children and so what you're going to want to do is start to build your application into where you have these little pockets of Really intense logic and data and that way when you're passing props, you're able to Not have to pass stuff, you know too many levels deep. I hope so if I yeah Yes, so this this I shared a link to this is in my slides Yeah, I'm almost done. I promise you should okay. Yeah Yeah, I think I shared a link, but if it didn't work, we'll figure it out for sure. Okay, so you guys are spying on me That's so wrong All right, so So this is going to get a little tricky. So what we want to do is We've at least wired it up. We can see the Yolo kind of working So we know we've we've passed this function down and it's doing what it's supposed to do So that's a good sign now. We can actually really work on the actual logic that's going to remove an item from the array So because our array is like a flat array here of just text What we're going to try to do is we're going to use the index that it's in the array to figure out how to remove it If we were working with WordPress this array would probably be an array of post objects And those posts would have an ID and it would be really easy to kind of like loop through this array and find the ID That was getting deleted But in our case, we're just going to use an index so if we Go over to our list You can see that we have an index here and we passed it as a key So what we're going to do is we're going to add one more prop called index And we're just going to pass that index to the list item. Then we're going to go update our list item component to get an index And then what we're going to do is we're going to switch this up a little bit So you can just pass the name of the function and it'll execute the function But you can also in here just do an anonymous function like this with got a love arrow functions And you're going to get an event and then over here you can call this function And so I can pass the event so real quick what you see there is the same as This I didn't do anything different But the reason I'm doing this though is because I want to pass another property, which is this index that I got So as I loop through and I build these list items Using kind of closures and all that stuff we talked about in the first talk It it still knows about this index It knows what number it was and it remembers it and I'm able to pass that along to this on remove function So that it has the index And so if I go over here to my remove item And I update it to get Something I'm just gonna call it item index. This is the index. It's now going to get two items Thank you And then what we're going to do is we're going to do this dot set state We're gonna set some state Again, I'm going to do const data equals this dot state and Then inside of here, I can say data Equals and I'm there's a lot of ways you could do those probably better ways, but man I just love looping and filtering so I'm gonna get an item and I'm just gonna say that And I'm gonna get the index Again when you use map and filter you usually just use the item and get the item But it does pass you the index and what that means is that we can just go and say so long as item Index so the index that got clicked as long as that index isn't the current index I'm looping through then return it and what that means is that the index of the item I did click on gets removed from the array Yeah So you see when I click item 2 item 1 it removes it from the array and so what's happening Let's we'll recap that because it's a bit convoluted So when I this item 1 this button it remembers that it was index 0 So when I click this button and this function fires This right here is 0 and then I go and loop through the array again So the first time I loop through the first item I get to this is 0 So the first item in the array is 0 and the item that was clicked was 0 So since 0 does equal 0 it doesn't get put into this new data So that's essentially making this happen where that it returns an entirely new array Minus that one because those indexes matched All right, so that's the live coding part. It worked Just a few slides Yeah, let me make sure So I have a little bit more. I have like five minutes. I promise Okay, 10 minutes promise. All right, so I've saved all the files So hopefully they do load for you All right, so kind of recapping you know JSX It's very much like HTML but the end of day react is converting that into its its react that create element Which at the end of day is just the JavaScript create element. So nothing special You know why we use it One of the things that people don't like about JSX is they hate the fact that they have their JavaScript in there They're HTML and there they might even have their CSS in there And people don't like that because of the whole separations concerns, which is a valid argument But what we react is taking is that we are doing a separation of concerns where we're separating it not by tech not technology HTML versus JavaScript, but we're we're separating our concerns on a component component based level So what usually happens in a react application is you'll have like that list dot JS element And you'll have like a list dot CSS with your CSS and they'll be to you know together And then you may even write unit tests and you'll have list dot test dot JS right there And so everything for that component is all in one spot right for side-by-side together And that's how we kind of separate our concerns out in react where We're breaking our component down on a component basis not on a technology basis This is an example of how to create a functional stateless component An example that we saw about creating a stateful component so we can actually have states that state we can have additional things going on One of the things we didn't talk about yet, and you're going to see in the next talk is life cycle methods So react comes with a whole bunch of events essentially that happen during the life cycle of a component from when it's about to get rendered To when it is rendered to when it gets taken away And these are very crucial for being able to do actual application work and react and there's I think there's about 8 to 12 of them But I'm just going to cover I think for so component did mount is probably the most important one You're going to use you're going to use this for initializing a whole bunch of stuff when a component first loads and More importantly, you're going to use this to fetch data So this is the place where you're going to want to actually go and fetch your posts from WordPress or whatever REST API you're connecting to Component will receive props So this is important if you have a component and you're going to see this later today If you have a component let's say it mounts and it's a post and it's showing a post and then For somehow some state changes to go show another post well because it's already mounted It's not going to go and fetch or do anything new again So this is your chance to hook in and be like does this post ID match this post ID if not We need to refetch and so this allows you to tell an already mounted component that it needs to update itself because it won't know inherently These are functions So you're going to get what's called next props You're going to get what the next props are and you can use those next props to compare to the current state to know Where you're at you'll see this later and so it'll make more sense, but it's a very another very useful one to know Should component update so before component will update when it receives new props You can actually hook in and tell it not to So react does a pretty good job of trying to figure out what should render when but every now and then it's not right And so you can do some performance improvements by if you catch some stuff That's rendering that you feel like shouldn't be rendering based on a current state change you can tell it not to And then another function is component will unmount This is just hand helpful if you're if you have some like event listeners or you're hooked into some stuff You're going to want to like unregister those events or things like that because if not you'll have what's called like phantom views Any any backbone fans in the world? Phantom views right so if you've done backbone phantom views is like all you ever deal with it seems like But you'll want to unregister from stuff and this is a great way to do that React DOM we talked about that. It's a separate package And it's what let it's what we use on the web to kind of inject our app into our document We have our events in our set states. So it's just some examples there Children so you can actually we didn't do this But you can actually insert other components into parent components like this and all you have to do is they get passed as Props and the proper it gets passed as is called children So so long as you render this that props that children it'll actually output these rows that were nested inside of it And last but not least if you want to get started in react development Don't worry about that Babel or webpack go get create react app Which is the best boiler starter kind of kit that you can get you just install this via npm with one line of On the command line and you're up and running and you'll have everything you need to start writing react on your local install And that's it


Hey everybody forced here up in a box of 2021 prison football team all for Jeffrey M. Here we go, man Let's go Jeffrey. See a red and yellow Trevor Lawrence right here. That's pretty good At football I don't know Anthony I will email Lane before I leave so that he sees an email in the morning Sometimes he can take a couple days. So I wouldn't worry about it too much But yeah gates and Ryan get a race to make math rookie. They desphits Patrick silver rookie Eric Stokes and Red and yellow Tyler Higbee Number 31 of 39 that's gonna do it for the box there Jeffrey appreciate the order for you We'll get it out to you


Hi everyone, happy Sunday. I'm Joe coming at you with 2021 Panini prism draft picks football random pack break one box Random pack break number 17. So we're gonna select a box and it's out of a fresh case, too We're gonna select a box number the packs then we'll randomize your names randomize the pack numbers match you up with something And hopefully we get something pretty cool out of here So you can see the sticker right there 2021 Panini prism draft picks football still in their college gear on this case Let's Just roll a die and we'll just kind of keep rolling the dice until we find a box that we're gonna do how about that? We'll go we'll go select a column first one two three for the left side four five six for the right side And it's six right side And then we'll split this in half One two three for the left side four five six for the right side To left side and split this again one two three for the left side four five six for the right side right side and then Once again, one two three four five six. That's the one we're gonna do. All right So I actually printed out labels for this so I can label the packs Packs numbered up now. Let's go get some new dice virtual dice right there big Thanks to Eric Chad and Robert for getting on this one. We're gonna randomize you a pack number Let's see what you get One and a four five times One two three four and five fifth and final time easy and One and a four five times for the numbers one two three four and five After five we got five four one three two All right, Robert with five four and two Eric with one Chad with three Let's do this Guess we'll do this alphabetically. Let's sort by column a So Chad will go with you first. In fact Hang tight for a second. I'm gonna I'm gonna print out the labels for this as well. So I could Put it on our team bags Sunday the 18th 21 Prism draft Football one box RP random pack number 17 there's Chad Good luck. So pack three for Chad is the one right in the middle. Good luck Miles Sanders George Kittle by the Antonio Gibson Red Wave Gardner Minshew to 299 Larry Fitzgerald Micah Parsons Tyler Vaughn's All right, let's see who the auto is gonna be Chad. Good luck The autograph is gonna be Elijah Moore From Ole Miss and that is numbered 22 out of 199 think Jets, maybe I think it's in playing time all right, so Chad, thank you giving that a shot Eric, you've got pack one and then Robert. You've got the rest. Here's pack one for Eric C Good luck. There's the autograph. I don't want to reveal that too early I might have kind of saw the color of the team there. There's Michael Carter 25 Najee Harris to 199 Wentz Jamar Chase Carlos Basham and behind Chase Claypool your auto is gonna be Jacoby Stevens Rookie Auto out of LSU in that hyper parallel Thank you, Eric. Appreciate it. All right, Robert. You've got the rest Two four and five. There's a Mari Cooper Red Wave Jacob Eason to 249 Garoppolo, I'm gonna show the autograph too early there. Oh, there's two autographs in there What's going on here? All right. Well first we got Kerry Angeline Rookie Auto, I don't know why the other ones flipped around is that a bonus or is that just a Card that was flipped around. We'll see that's 10 out of 199 And what's the story behind Jimmy Garoppolo? No, it's nothing. It's just another card that was flipped around it happens Hopefully the autograph should be on the back right there. All right, so we got Rookine Boyd Red Wave Chase Young to 199 and an all-american Silver Trevor Lawrence. Nice You got a Justin Fields here as well And behind Julian Edelman is your auto and that's gonna be Marvin Wilson Silver autograph. Nice. Silver Trevor Lawrence. All right, and the last pack Sean Wade Red Wave Jason Owa to 249, Kenneth Gainwell Silver, Jamie Newman, Joseph Osai, Jarrett Goff, and behind Debo is a Chaz Sarat Mojo Refractor Autograph 12 out of 25 Thanks Robert. Thanks Chad. Thanks Eric for getting these packs. We've got another box in the store and we can keep hunting The the big names for this year. I'm Joe for Jasper's casewrakes.com. I'll see you next time for the next one. Bye. You