diff --git "a/react_retrieval.json" "b/react_retrieval.json" deleted file mode 100644--- "a/react_retrieval.json" +++ /dev/null @@ -1,600 +0,0 @@ -[ - { - "id": "bd9e83073a0a", - "url": "https://react.dev/learn", - "title": "Quick Start – React", - "content": "Learn React Quick Start Welcome to the React documentation! This page will give you an introduction to 80% of the React concepts that you will use on a daily basis. You will learn How to create and nest components How to add markup and styles How to display data How to render conditions and lists How to respond to events and update the screen How to share data between components Creating and nesting components React apps are made out of components. A component is a piece of the UI (user interface) that has its own logic and appearance. A component can be as small as a button, or as large as an entire page. React components are JavaScript functions that return markup: \n\n```\nfunction MyButton() { return ( );}\n```\n\n Now that you’ve declared \n\n```\nMyButton\n```\n\n, you can nest it into another component: \n\n```\nexport default function MyApp() { return (

Welcome to my app

);}\n```\n\n Notice that \n\n```\n\n```\n\n starts with a capital letter. That’s how you know it’s a React component. React component names must always start with a capital letter, while HTML tags must be lowercase. Have a look at the result: App. js App. js Reload Clear Fork \n\n```\nfunction MyButton() {\n return (\n \n );\n}\nexport default function MyApp() {\n return (\n
\n

Welcome to my app

\n \n
\n );\n}\n```\n\n Show more The \n\n```\nexport default\n```\n\n keywords specify the main component in the file. If you’re not familiar with some piece of JavaScript syntax, MDN and javascript. info have great references. Writing markup with JSX The markup syntax you’ve seen above is called JSX. It is optional, but most React projects use JSX for its convenience. All of the tools we recommend for local development support JSX out of the box. JSX is stricter than HTML. You have to close tags like \n\n```\n
\n```\n\n. Your component also can’t return multiple JSX tags. You have to wrap them into a shared parent, like a \n\n```\n
...
\n```\n\n or an empty \n\n```\n<>...\n```\n\n wrapper: \n\n```\nfunction AboutPage() { return ( <>

About

Hello there.
How do you do?

);}\n```\n\n If you have a lot of HTML to port to JSX, you can use an online converter. Adding styles In React, you specify a CSS class with \n\n```\nclassName\n```\n\n. It works the same way as the HTML \n\n```\nclass\n```\n\n attribute: \n\n```\n\n```\n\n Then you write the CSS rules for it in a separate CSS file: \n\n```\n/* In your CSS */.avatar { border-radius: 50%;}\n```\n\n React does not prescribe how you add CSS files. In the simplest case, you’ll add a \n\n```\n\n```\n\n tag to your HTML. If you use a build tool or a framework, consult its documentation to learn how to add a CSS file to your project. Displaying data JSX lets you put markup into JavaScript. Curly braces let you “escape back” into JavaScript so that you can embed some variable from your code and display it to the user. For example, this will display \n\n```\nuser.name\n```\n\n: \n\n```\nreturn (

{user.name}

);\n```\n\n You can also “escape into JavaScript” from JSX attributes, but you have to use curly braces instead of quotes. For example, \n\n```\nclassName=\"avatar\"\n```\n\n passes the \n\n```\n\"avatar\"\n```\n\n string as the CSS class, but \n\n```\nsrc={user.imageUrl}\n```\n\n reads the JavaScript \n\n```\nuser.imageUrl\n```\n\n variable value, and then passes that value as the \n\n```\nsrc\n```\n\n attribute: \n\n```\nreturn ( );\n```\n\n You can put more complex expressions inside the JSX curly braces too, for example, string concatenation: App. js App. js Reload Clear Fork \n\n```\nconst user = {\n name: 'Hedy Lamarr',\n imageUrl: 'https://i.imgur.com/yXOvdOSs.jpg',\n imageSize: 90,\n};\nexport default function Profile() {\n return (\n <>\n

{user.name}

\n \n \n );\n}\n```\n\n Show more In the above example, \n\n```\nstyle={{}}\n```\n\n is not a special syntax, but a regular \n\n```\n{}\n```\n\n object inside the \n\n```\nstyle={ }\n```\n\n JSX curly braces. You can use the \n\n```\nstyle\n```\n\n attribute when your styles depend on JavaScript variables. Conditional rendering In React, there is no special syntax for writing conditions. Instead, you’ll use the same techniques as you use when writing regular JavaScript code. For example, you can use an \n\n```\nif\n```\n\n statement to conditionally include JSX: \n\n```\nlet content;if (isLoggedIn) { content = ;} else { content = ;}return (
{content}
);\n```\n\n If you prefer more compact code, you can use the conditional \n\n```\n?\n```\n\n operator. Unlike \n\n```\nif\n```\n\n, it works inside JSX: \n\n```\n
{isLoggedIn ? ( ) : ( )}
\n```\n\n When you don’t need the \n\n```\nelse\n```\n\n branch, you can also use a shorter logical \n\n```\n&&\n```\n\n syntax: \n\n```\n
{isLoggedIn && }
\n```\n\n All of these approaches also work for conditionally specifying attributes. If you’re unfamiliar with some of this JavaScript syntax, you can start by always using \n\n```\nif...else\n```\n\n. Rendering lists You will rely on JavaScript features like \n\n```\nfor\n```\n\n loop and the array \n\n```\nmap()\n```\n\n function to render lists of components. For example, let’s say you have an array of products: \n\n```\nconst products = [ { title: 'Cabbage', id: 1 }, { title: 'Garlic', id: 2 }, { title: 'Apple', id: 3 },];\n```\n\n Inside your component, use the \n\n```\nmap()\n```\n\n function to transform an array of products into an array of \n\n```\n
  • \n```\n\n items: \n\n```\nconst listItems = products.map(product =>
  • {product.title}
  • );return (
      {listItems}
    );\n```\n\n Notice how \n\n```\n
  • \n```\n\n has a \n\n```\nkey\n```\n\n attribute. For each item in a list, you should pass a string or a number that uniquely identifies that item among its siblings. Usually, a key should be coming from your data, such as a database ID. React uses your keys to know what happened if you later insert, delete, or reorder the items. App. js App. js Reload Clear Fork \n\n```\nconst products = [\n { title: 'Cabbage', isFruit: false, id: 1 },\n { title: 'Garlic', isFruit: false, id: 2 },\n { title: 'Apple', isFruit: true, id: 3 },\n];\nexport default function ShoppingList() {\n const listItems = products.map(product =>\n \n {product.title}\n
  • \n );\n return (\n
      {listItems}
    \n );\n}\n```\n\n Show more Responding to events You can respond to events by declaring event handler functions inside your components: \n\n```\nfunction MyButton() { function handleClick() { alert('You clicked me!'); } return ( );}\n```\n\n Notice how \n\n```\nonClick={handleClick}\n```\n\n has no parentheses at the end! Do not call the event handler function: you only need to pass it down. React will call your event handler when the user clicks the button. Updating the screen Often, you’ll want your component to “remember” some information and display it. For example, maybe you want to count the number of times a button is clicked. To do this, add state to your component. First, import \n\n```\nuseState\n```\n\n from React: \n\n```\nimport { useState } from 'react';\n```\n\n Now you can declare a state variable inside your component: \n\n```\nfunction MyButton() { const [count, setCount] = useState(0); // ...\n```\n\n You’ll get two things from \n\n```\nuseState\n```\n\n: the current state ( \n\n```\ncount\n```\n\n ), and the function that lets you update it ( \n\n```\nsetCount\n```\n\n ). You can give them any names, but the convention is to write \n\n```\n[something, setSomething]\n```\n\n. The first time the button is displayed, \n\n```\ncount\n```\n\n will be \n\n```\n0\n```\n\n because you passed \n\n```\n0\n```\n\n to \n\n```\nuseState()\n```\n\n. When you want to change state, call \n\n```\nsetCount()\n```\n\n and pass the new value to it. Clicking this button will increment the counter: \n\n```\nfunction MyButton() { const [count, setCount] = useState(0); function handleClick() { setCount(count + 1); } return ( );}\n```\n\n React will call your component function again. This time, \n\n```\ncount\n```\n\n will be \n\n```\n1\n```\n\n. Then it will be \n\n```\n2\n```\n\n. And so on. If you render the same component multiple times, each will get its own state. Click each button separately: App. js App. js Reload Clear Fork \n\n```\nimport { useState } from 'react';\nexport default function MyApp() {\n return (\n
    \n

    Counters that update separately

    \n \n \n
    \n );\n}\nfunction MyButton() {\n const [count, setCount] = useState(0);\n function handleClick() {\n setCount(count + 1);\n }\n return (\n \n );\n}\n```\n\n Show more Notice how each button “remembers” its own \n\n```\ncount\n```\n\n state and doesn’t affect other buttons. Using Hooks Functions starting with \n\n```\nuse\n```\n\n are called Hooks. \n\n```\nuseState\n```\n\n is a built-in Hook provided by React. You can find other built-in Hooks in the API reference. You can also write your own Hooks by combining the existing ones. Hooks are more restrictive than other functions. You can only call Hooks at the top of your components (or other Hooks). If you want to use \n\n```\nuseState\n```\n\n in a condition or a loop, extract a new component and put it there. Sharing data between components In the previous example, each \n\n```\nMyButton\n```\n\n had its own independent \n\n```\ncount\n```\n\n, and when each button was clicked, only the \n\n```\ncount\n```\n\n for the button clicked changed: Initially, each \n\n```\nMyButton\n```\n\n ’s \n\n```\ncount\n```\n\n state is \n\n```\n0\n```\n\n The first \n\n```\nMyButton\n```\n\n updates its \n\n```\ncount\n```\n\n to \n\n```\n1\n```\n\n However, often you’ll need components to share data and always update together. To make both \n\n```\nMyButton\n```\n\n components display the same \n\n```\ncount\n```\n\n and update together, you need to move the state from the individual buttons “upwards” to the closest component containing all of them. In this example, it is \n\n```\nMyApp\n```\n\n: Initially, \n\n```\nMyApp\n```\n\n ’s \n\n```\ncount\n```\n\n state is \n\n```\n0\n```\n\n and is passed down to both children On click, \n\n```\nMyApp\n```\n\n updates its \n\n```\ncount\n```\n\n state to \n\n```\n1\n```\n\n and passes it down to both children Now when you click either button, the \n\n```\ncount\n```\n\n in \n\n```\nMyApp\n```\n\n will change, which will change both of the counts in \n\n```\nMyButton\n```\n\n. Here’s how you can express this in code. First, move the state up from \n\n```\nMyButton\n```\n\n into \n\n```\nMyApp\n```\n\n: \n\n```\nexport default function MyApp() { const [count, setCount] = useState(0); function handleClick() { setCount(count + 1); } return (

    Counters that update separately

    );}function MyButton() { // ... we're moving code from here ...}\n```\n\n Then, pass the state down from \n\n```\nMyApp\n```\n\n to each \n\n```\nMyButton\n```\n\n, together with the shared click handler. You can pass information to \n\n```\nMyButton\n```\n\n using the JSX curly braces, just like you previously did with built-in tags like \n\n```\n\n```\n\n: \n\n```\nexport default function MyApp() { const [count, setCount] = useState(0); function handleClick() { setCount(count + 1); } return (

    Counters that update together

    );}\n```\n\n The information you pass down like this is called props. Now the \n\n```\nMyApp\n```\n\n component contains the \n\n```\ncount\n```\n\n state and the \n\n```\nhandleClick\n```\n\n event handler, and passes both of them down as props to each of the buttons. Finally, change \n\n```\nMyButton\n```\n\n to read the props you have passed from its parent component: \n\n```\nfunction MyButton({ count, onClick }) { return ( );}\n```\n\n When you click the button, the \n\n```\nonClick\n```\n\n handler fires. Each button’s \n\n```\nonClick\n```\n\n prop was set to the \n\n```\nhandleClick\n```\n\n function inside \n\n```\nMyApp\n```\n\n, so the code inside of it runs. That code calls \n\n```\nsetCount(count + 1)\n```\n\n, incrementing the \n\n```\ncount\n```\n\n state variable. The new \n\n```\ncount\n```\n\n value is passed as a prop to each button, so they all show the new value. This is called “lifting state up”. By moving state up, you’ve shared it between components. App. js App. js Reload Clear Fork \n\n```\nimport { useState } from 'react';\nexport default function MyApp() {\n const [count, setCount] = useState(0);\n function handleClick() {\n setCount(count + 1);\n }\n return (\n
    \n

    Counters that update together

    \n \n \n
    \n );\n}\nfunction MyButton({ count, onClick }) {\n return (\n \n );\n}\n```\n\n Show more Next Steps By now, you know the basics of how to write React code! Check out the Tutorial to put them into practice and build your first mini-app with React. Next Tutorial: Tic-Tac-Toe", - "metadata": { - "source_type": "general", - "quality_score": 9.5, - "coherence_score": 7.0, - "word_count": 2184, - "timestamp": "2025-09-03 07:32:46" - } - }, - { - "id": "91d495251548", - "url": "https://react.dev/reference", - "title": "React Reference Overview – React", - "content": "API Reference React Reference Overview This section provides detailed reference documentation for working with React. For an introduction to React, please visit the Learn section. The React reference documentation is broken down into functional subsections: React Programmatic React features: Hooks - Use different React features from your components. Components - Built-in components that you can use in your JSX. APIs - APIs that are useful for defining components. Directives - Provide instructions to bundlers compatible with React Server Components. React DOM React-dom contains features that are only supported for web applications (which run in the browser DOM environment). This section is broken into the following: Hooks - Hooks for web applications which run in the browser DOM environment. Components - React supports all of the browser built-in HTML and SVG components. APIs - The \n\n```\nreact-dom\n```\n\n package contains methods supported only in web applications. Client APIs - The \n\n```\nreact-dom/client\n```\n\n APIs let you render React components on the client (in the browser). Server APIs - The \n\n```\nreact-dom/server\n```\n\n APIs let you render React components to HTML on the server. React Compiler The React Compiler is a build-time optimization tool that automatically memoizes your React components and values: Configuration - Configuration options for React Compiler. Directives - Function-level directives to control compilation. Compiling Libraries - Guide for shipping pre-compiled library code. Rules of React has idioms — or rules — for how to express patterns in a way that is easy to understand and yields high-quality applications: Components and Hooks must be pure – Purity makes your code easier to understand, debug, and allows React to automatically optimize your components and hooks correctly. React calls Components and Hooks – React is responsible for rendering components and hooks when necessary to optimize the user experience. Rules of Hooks – Hooks are defined using JavaScript functions, but they represent a special type of reusable UI logic with restrictions on where they can be called. Legacy APIs Legacy APIs - Exported from the \n\n```\nreact\n```\n\n package, but not recommended for use in newly written code. Next Hooks", - "metadata": { - "source_type": "general", - "quality_score": 9.5, - "coherence_score": 7.0, - "word_count": 347, - "timestamp": "2025-09-03 07:32:46" - } - }, - { - "id": "5a97a21efd5e", - "url": "https://reactjs.org/docs/getting-started.html", - "title": "Quick Start – React", - "content": "Learn React Quick Start Welcome to the React documentation! This page will give you an introduction to 80% of the React concepts that you will use on a daily basis. You will learn How to create and nest components How to add markup and styles How to display data How to render conditions and lists How to respond to events and update the screen How to share data between components Creating and nesting components React apps are made out of components. A component is a piece of the UI (user interface) that has its own logic and appearance. A component can be as small as a button, or as large as an entire page. React components are JavaScript functions that return markup: \n\n```\nfunction MyButton() { return ( );}\n```\n\n Now that you’ve declared \n\n```\nMyButton\n```\n\n, you can nest it into another component: \n\n```\nexport default function MyApp() { return (

    Welcome to my app

    );}\n```\n\n Notice that \n\n```\n\n```\n\n starts with a capital letter. That’s how you know it’s a React component. React component names must always start with a capital letter, while HTML tags must be lowercase. Have a look at the result: App. js App. js Reload Clear Fork \n\n```\nfunction MyButton() {\n return (\n \n );\n}\nexport default function MyApp() {\n return (\n
    \n

    Welcome to my app

    \n \n
    \n );\n}\n```\n\n Show more The \n\n```\nexport default\n```\n\n keywords specify the main component in the file. If you’re not familiar with some piece of JavaScript syntax, MDN and javascript. info have great references. Writing markup with JSX The markup syntax you’ve seen above is called JSX. It is optional, but most React projects use JSX for its convenience. All of the tools we recommend for local development support JSX out of the box. JSX is stricter than HTML. You have to close tags like \n\n```\n
    \n```\n\n. Your component also can’t return multiple JSX tags. You have to wrap them into a shared parent, like a \n\n```\n
    ...
    \n```\n\n or an empty \n\n```\n<>...\n```\n\n wrapper: \n\n```\nfunction AboutPage() { return ( <>

    About

    Hello there.
    How do you do?

    );}\n```\n\n If you have a lot of HTML to port to JSX, you can use an online converter. Adding styles In React, you specify a CSS class with \n\n```\nclassName\n```\n\n. It works the same way as the HTML \n\n```\nclass\n```\n\n attribute: \n\n```\n\n```\n\n Then you write the CSS rules for it in a separate CSS file: \n\n```\n/* In your CSS */.avatar { border-radius: 50%;}\n```\n\n React does not prescribe how you add CSS files. In the simplest case, you’ll add a \n\n```\n\n```\n\n tag to your HTML. If you use a build tool or a framework, consult its documentation to learn how to add a CSS file to your project. Displaying data JSX lets you put markup into JavaScript. Curly braces let you “escape back” into JavaScript so that you can embed some variable from your code and display it to the user. For example, this will display \n\n```\nuser.name\n```\n\n: \n\n```\nreturn (

    {user.name}

    );\n```\n\n You can also “escape into JavaScript” from JSX attributes, but you have to use curly braces instead of quotes. For example, \n\n```\nclassName=\"avatar\"\n```\n\n passes the \n\n```\n\"avatar\"\n```\n\n string as the CSS class, but \n\n```\nsrc={user.imageUrl}\n```\n\n reads the JavaScript \n\n```\nuser.imageUrl\n```\n\n variable value, and then passes that value as the \n\n```\nsrc\n```\n\n attribute: \n\n```\nreturn ( );\n```\n\n You can put more complex expressions inside the JSX curly braces too, for example, string concatenation: App. js App. js Reload Clear Fork \n\n```\nconst user = {\n name: 'Hedy Lamarr',\n imageUrl: 'https://i.imgur.com/yXOvdOSs.jpg',\n imageSize: 90,\n};\nexport default function Profile() {\n return (\n <>\n

    {user.name}

    \n \n \n );\n}\n```\n\n Show more In the above example, \n\n```\nstyle={{}}\n```\n\n is not a special syntax, but a regular \n\n```\n{}\n```\n\n object inside the \n\n```\nstyle={ }\n```\n\n JSX curly braces. You can use the \n\n```\nstyle\n```\n\n attribute when your styles depend on JavaScript variables. Conditional rendering In React, there is no special syntax for writing conditions. Instead, you’ll use the same techniques as you use when writing regular JavaScript code. For example, you can use an \n\n```\nif\n```\n\n statement to conditionally include JSX: \n\n```\nlet content;if (isLoggedIn) { content = ;} else { content = ;}return (
    {content}
    );\n```\n\n If you prefer more compact code, you can use the conditional \n\n```\n?\n```\n\n operator. Unlike \n\n```\nif\n```\n\n, it works inside JSX: \n\n```\n
    {isLoggedIn ? ( ) : ( )}
    \n```\n\n When you don’t need the \n\n```\nelse\n```\n\n branch, you can also use a shorter logical \n\n```\n&&\n```\n\n syntax: \n\n```\n
    {isLoggedIn && }
    \n```\n\n All of these approaches also work for conditionally specifying attributes. If you’re unfamiliar with some of this JavaScript syntax, you can start by always using \n\n```\nif...else\n```\n\n. Rendering lists You will rely on JavaScript features like \n\n```\nfor\n```\n\n loop and the array \n\n```\nmap()\n```\n\n function to render lists of components. For example, let’s say you have an array of products: \n\n```\nconst products = [ { title: 'Cabbage', id: 1 }, { title: 'Garlic', id: 2 }, { title: 'Apple', id: 3 },];\n```\n\n Inside your component, use the \n\n```\nmap()\n```\n\n function to transform an array of products into an array of \n\n```\n
  • \n```\n\n items: \n\n```\nconst listItems = products.map(product =>
  • {product.title}
  • );return (
      {listItems}
    );\n```\n\n Notice how \n\n```\n
  • \n```\n\n has a \n\n```\nkey\n```\n\n attribute. For each item in a list, you should pass a string or a number that uniquely identifies that item among its siblings. Usually, a key should be coming from your data, such as a database ID. React uses your keys to know what happened if you later insert, delete, or reorder the items. App. js App. js Reload Clear Fork \n\n```\nconst products = [\n { title: 'Cabbage', isFruit: false, id: 1 },\n { title: 'Garlic', isFruit: false, id: 2 },\n { title: 'Apple', isFruit: true, id: 3 },\n];\nexport default function ShoppingList() {\n const listItems = products.map(product =>\n \n {product.title}\n
  • \n );\n return (\n
      {listItems}
    \n );\n}\n```\n\n Show more Responding to events You can respond to events by declaring event handler functions inside your components: \n\n```\nfunction MyButton() { function handleClick() { alert('You clicked me!'); } return ( );}\n```\n\n Notice how \n\n```\nonClick={handleClick}\n```\n\n has no parentheses at the end! Do not call the event handler function: you only need to pass it down. React will call your event handler when the user clicks the button. Updating the screen Often, you’ll want your component to “remember” some information and display it. For example, maybe you want to count the number of times a button is clicked. To do this, add state to your component. First, import \n\n```\nuseState\n```\n\n from React: \n\n```\nimport { useState } from 'react';\n```\n\n Now you can declare a state variable inside your component: \n\n```\nfunction MyButton() { const [count, setCount] = useState(0); // ...\n```\n\n You’ll get two things from \n\n```\nuseState\n```\n\n: the current state ( \n\n```\ncount\n```\n\n ), and the function that lets you update it ( \n\n```\nsetCount\n```\n\n ). You can give them any names, but the convention is to write \n\n```\n[something, setSomething]\n```\n\n. The first time the button is displayed, \n\n```\ncount\n```\n\n will be \n\n```\n0\n```\n\n because you passed \n\n```\n0\n```\n\n to \n\n```\nuseState()\n```\n\n. When you want to change state, call \n\n```\nsetCount()\n```\n\n and pass the new value to it. Clicking this button will increment the counter: \n\n```\nfunction MyButton() { const [count, setCount] = useState(0); function handleClick() { setCount(count + 1); } return ( );}\n```\n\n React will call your component function again. This time, \n\n```\ncount\n```\n\n will be \n\n```\n1\n```\n\n. Then it will be \n\n```\n2\n```\n\n. And so on. If you render the same component multiple times, each will get its own state. Click each button separately: App. js App. js Reload Clear Fork \n\n```\nimport { useState } from 'react';\nexport default function MyApp() {\n return (\n
    \n

    Counters that update separately

    \n \n \n
    \n );\n}\nfunction MyButton() {\n const [count, setCount] = useState(0);\n function handleClick() {\n setCount(count + 1);\n }\n return (\n \n );\n}\n```\n\n Show more Notice how each button “remembers” its own \n\n```\ncount\n```\n\n state and doesn’t affect other buttons. Using Hooks Functions starting with \n\n```\nuse\n```\n\n are called Hooks. \n\n```\nuseState\n```\n\n is a built-in Hook provided by React. You can find other built-in Hooks in the API reference. You can also write your own Hooks by combining the existing ones. Hooks are more restrictive than other functions. You can only call Hooks at the top of your components (or other Hooks). If you want to use \n\n```\nuseState\n```\n\n in a condition or a loop, extract a new component and put it there. Sharing data between components In the previous example, each \n\n```\nMyButton\n```\n\n had its own independent \n\n```\ncount\n```\n\n, and when each button was clicked, only the \n\n```\ncount\n```\n\n for the button clicked changed: Initially, each \n\n```\nMyButton\n```\n\n ’s \n\n```\ncount\n```\n\n state is \n\n```\n0\n```\n\n The first \n\n```\nMyButton\n```\n\n updates its \n\n```\ncount\n```\n\n to \n\n```\n1\n```\n\n However, often you’ll need components to share data and always update together. To make both \n\n```\nMyButton\n```\n\n components display the same \n\n```\ncount\n```\n\n and update together, you need to move the state from the individual buttons “upwards” to the closest component containing all of them. In this example, it is \n\n```\nMyApp\n```\n\n: Initially, \n\n```\nMyApp\n```\n\n ’s \n\n```\ncount\n```\n\n state is \n\n```\n0\n```\n\n and is passed down to both children On click, \n\n```\nMyApp\n```\n\n updates its \n\n```\ncount\n```\n\n state to \n\n```\n1\n```\n\n and passes it down to both children Now when you click either button, the \n\n```\ncount\n```\n\n in \n\n```\nMyApp\n```\n\n will change, which will change both of the counts in \n\n```\nMyButton\n```\n\n. Here’s how you can express this in code. First, move the state up from \n\n```\nMyButton\n```\n\n into \n\n```\nMyApp\n```\n\n: \n\n```\nexport default function MyApp() { const [count, setCount] = useState(0); function handleClick() { setCount(count + 1); } return (

    Counters that update separately

    );}function MyButton() { // ... we're moving code from here ...}\n```\n\n Then, pass the state down from \n\n```\nMyApp\n```\n\n to each \n\n```\nMyButton\n```\n\n, together with the shared click handler. You can pass information to \n\n```\nMyButton\n```\n\n using the JSX curly braces, just like you previously did with built-in tags like \n\n```\n\n```\n\n: \n\n```\nexport default function MyApp() { const [count, setCount] = useState(0); function handleClick() { setCount(count + 1); } return (

    Counters that update together

    );}\n```\n\n The information you pass down like this is called props. Now the \n\n```\nMyApp\n```\n\n component contains the \n\n```\ncount\n```\n\n state and the \n\n```\nhandleClick\n```\n\n event handler, and passes both of them down as props to each of the buttons. Finally, change \n\n```\nMyButton\n```\n\n to read the props you have passed from its parent component: \n\n```\nfunction MyButton({ count, onClick }) { return ( );}\n```\n\n When you click the button, the \n\n```\nonClick\n```\n\n handler fires. Each button’s \n\n```\nonClick\n```\n\n prop was set to the \n\n```\nhandleClick\n```\n\n function inside \n\n```\nMyApp\n```\n\n, so the code inside of it runs. That code calls \n\n```\nsetCount(count + 1)\n```\n\n, incrementing the \n\n```\ncount\n```\n\n state variable. The new \n\n```\ncount\n```\n\n value is passed as a prop to each button, so they all show the new value. This is called “lifting state up”. By moving state up, you’ve shared it between components. App. js App. js Reload Clear Fork \n\n```\nimport { useState } from 'react';\nexport default function MyApp() {\n const [count, setCount] = useState(0);\n function handleClick() {\n setCount(count + 1);\n }\n return (\n
    \n

    Counters that update together

    \n \n \n
    \n );\n}\nfunction MyButton({ count, onClick }) {\n return (\n \n );\n}\n```\n\n Show more Next Steps By now, you know the basics of how to write React code! Check out the Tutorial to put them into practice and build your first mini-app with React. Next Tutorial: Tic-Tac-Toe", - "metadata": { - "source_type": "general", - "quality_score": 9.5, - "coherence_score": 7.0, - "word_count": 2184, - "timestamp": "2025-09-03 07:32:46" - } - }, - { - "id": "3bb87b3dbc3f", - "url": "https://overreacted.io/", - "title": "overreacted — A blog by Dan Abramov", - "content": "Lean for JavaScript Developers September 2, 2025 Programming with proofs. Beyond Booleans August 16, 2025 What is the type of 2 + 2 = 4? The Math Is Haunted July 30, 2025 A taste of Lean. Suppressions of Suppressions June 11, 2025 I heard you like linting. I'm Doing a Little Consulting June 11, 2025 Personal update post. How Imports Work in RSC June 5, 2025 A layered module system. RSC for LISP Developers June 1, 2025 Quoting for modules. Progressive JSON May 31, 2025 Why streaming isn't enough. Why Does RSC Integrate with a Bundler? May 30, 2025 One does not simply serialize a module. One Roundtrip Per Navigation May 29, 2025 What do HTML, GraphQL, and RSC have in common? Static as a Server May 8, 2025 You wouldn't download a site. RSC for Astro Developers May 6, 2025 Islands, but make it fractal. Functional HTML May 2, 2025 Tags on both sides. What Does \"use client\" Do? April 25, 2025 Two worlds, two doors. Impossible Components April 22, 2025 Composing across the stack. JSX Over The Wire April 16, 2025 Turning your API inside-out. React for Two Computers April 9, 2025 Two things, one origin. The Two Reacts January 4, 2024 UI = f(data)(state) A Chain Reaction December 11, 2023 The limits of my language mean the limits of my world. npm audit: Broken by Design July 7, 2021 Found 99 vulnerabilities (84 moderately irrelevant, 15 highly irrelevant) Before You memo() February 23, 2021 Rendering optimizations that come naturally. The WET Codebase July 13, 2020 Come waste your time with me. Goodbye, Clean Code January 11, 2020 Let clean code guide you. Then let it go. My Decade in Review January 1, 2020 A personal reflection. What Are the React Team Principles? December 25, 2019 UI Before API. On let vs const December 22, 2019 So which one should I use? What Is JavaScript Made Of? December 20, 2019 Getting a closure on JavaScript. How Does the Development Mode Work? August 4, 2019 Dead code elimination by convention. Algebraic Effects for the Rest of Us July 21, 2019 They’re not burritos. Preparing for a Tech Talk, Part 3: Content July 10, 2019 Turning an idea into a talk. Name It, and They Will Come March 25, 2019 A change starts with a story. Writing Resilient Components March 16, 2019 Four principles to set you on the right path. A Complete Guide to useEffect March 9, 2019 Effects are a part of your data flow. How Are Function Components Different from Classes? March 3, 2019 They’re a whole different Pokémon. Coping with Feedback March 2, 2019 Sometimes I can’t fall asleep. Fix Like No One’s Watching February 15, 2019 The other kind of technical debt. Making setInterval Declarative with React Hooks February 4, 2019 How I learned to stop worrying and love refs. React as a UI Runtime February 2, 2019 An in-depth description of the React programming model. Why Isn’t X a Hook? January 26, 2019 Just because we can, doesn’t mean we should. The “Bug-O” Notation January 25, 2019 What is the 🐞(n) of your API? Preparing for a Tech Talk, Part 2: What, Why, and How January 7, 2019 We need to go deeper. The Elements of UI Engineering December 30, 2018 What makes UI engineering difficult? Things I Don’t Know as of 2018 December 28, 2018 We can admit our knowledge gaps without devaluing our expertise. Preparing for a Tech Talk, Part 1: Motivation December 26, 2018 Here’s my recipe for a good talk idea. Why Do React Hooks Rely on Call Order? December 13, 2018 Lessons learned from mixins, render props, HOCs, and classes. Optimized for Change December 12, 2018 What makes a great API? How Does setState Know What to Do? December 9, 2018 Dependency injection is nice if you don’t have to think about it. My Wishlist for Hot Reloading December 8, 2018 I don't want a lot for Christmas. There is just one thing I need. Why Do React Elements Have a $$typeof Property? December 3, 2018 It has something to do with security. How Does React Tell a Class from a Function? December 2, 2018 We talk about classes, new, instanceof, prototype chains, and API design. Why Do We Write super(props)? November 30, 2018 There’s a twist at the end.", - "metadata": { - "source_type": "general", - "quality_score": 9.5, - "coherence_score": 6.0, - "word_count": 721, - "timestamp": "2025-09-03 07:32:46" - } - }, - { - "id": "3c91f6c3070d", - "url": "https://beta.reactjs.org/learn", - "title": "Quick Start – React", - "content": "Learn React Quick Start Welcome to the React documentation! This page will give you an introduction to 80% of the React concepts that you will use on a daily basis. You will learn How to create and nest components How to add markup and styles How to display data How to render conditions and lists How to respond to events and update the screen How to share data between components Creating and nesting components React apps are made out of components. A component is a piece of the UI (user interface) that has its own logic and appearance. A component can be as small as a button, or as large as an entire page. React components are JavaScript functions that return markup: \n\n```\nfunction MyButton() { return ( );}\n```\n\n Now that you’ve declared \n\n```\nMyButton\n```\n\n, you can nest it into another component: \n\n```\nexport default function MyApp() { return (

    Welcome to my app

    );}\n```\n\n Notice that \n\n```\n\n```\n\n starts with a capital letter. That’s how you know it’s a React component. React component names must always start with a capital letter, while HTML tags must be lowercase. Have a look at the result: App. js App. js Reload Clear Fork \n\n```\nfunction MyButton() {\n return (\n \n );\n}\nexport default function MyApp() {\n return (\n
    \n

    Welcome to my app

    \n \n
    \n );\n}\n```\n\n Show more The \n\n```\nexport default\n```\n\n keywords specify the main component in the file. If you’re not familiar with some piece of JavaScript syntax, MDN and javascript. info have great references. Writing markup with JSX The markup syntax you’ve seen above is called JSX. It is optional, but most React projects use JSX for its convenience. All of the tools we recommend for local development support JSX out of the box. JSX is stricter than HTML. You have to close tags like \n\n```\n
    \n```\n\n. Your component also can’t return multiple JSX tags. You have to wrap them into a shared parent, like a \n\n```\n
    ...
    \n```\n\n or an empty \n\n```\n<>...\n```\n\n wrapper: \n\n```\nfunction AboutPage() { return ( <>

    About

    Hello there.
    How do you do?

    );}\n```\n\n If you have a lot of HTML to port to JSX, you can use an online converter. Adding styles In React, you specify a CSS class with \n\n```\nclassName\n```\n\n. It works the same way as the HTML \n\n```\nclass\n```\n\n attribute: \n\n```\n\n```\n\n Then you write the CSS rules for it in a separate CSS file: \n\n```\n/* In your CSS */.avatar { border-radius: 50%;}\n```\n\n React does not prescribe how you add CSS files. In the simplest case, you’ll add a \n\n```\n\n```\n\n tag to your HTML. If you use a build tool or a framework, consult its documentation to learn how to add a CSS file to your project. Displaying data JSX lets you put markup into JavaScript. Curly braces let you “escape back” into JavaScript so that you can embed some variable from your code and display it to the user. For example, this will display \n\n```\nuser.name\n```\n\n: \n\n```\nreturn (

    {user.name}

    );\n```\n\n You can also “escape into JavaScript” from JSX attributes, but you have to use curly braces instead of quotes. For example, \n\n```\nclassName=\"avatar\"\n```\n\n passes the \n\n```\n\"avatar\"\n```\n\n string as the CSS class, but \n\n```\nsrc={user.imageUrl}\n```\n\n reads the JavaScript \n\n```\nuser.imageUrl\n```\n\n variable value, and then passes that value as the \n\n```\nsrc\n```\n\n attribute: \n\n```\nreturn ( );\n```\n\n You can put more complex expressions inside the JSX curly braces too, for example, string concatenation: App. js App. js Reload Clear Fork \n\n```\nconst user = {\n name: 'Hedy Lamarr',\n imageUrl: 'https://i.imgur.com/yXOvdOSs.jpg',\n imageSize: 90,\n};\nexport default function Profile() {\n return (\n <>\n

    {user.name}

    \n \n \n );\n}\n```\n\n Show more In the above example, \n\n```\nstyle={{}}\n```\n\n is not a special syntax, but a regular \n\n```\n{}\n```\n\n object inside the \n\n```\nstyle={ }\n```\n\n JSX curly braces. You can use the \n\n```\nstyle\n```\n\n attribute when your styles depend on JavaScript variables. Conditional rendering In React, there is no special syntax for writing conditions. Instead, you’ll use the same techniques as you use when writing regular JavaScript code. For example, you can use an \n\n```\nif\n```\n\n statement to conditionally include JSX: \n\n```\nlet content;if (isLoggedIn) { content = ;} else { content = ;}return (
    {content}
    );\n```\n\n If you prefer more compact code, you can use the conditional \n\n```\n?\n```\n\n operator. Unlike \n\n```\nif\n```\n\n, it works inside JSX: \n\n```\n
    {isLoggedIn ? ( ) : ( )}
    \n```\n\n When you don’t need the \n\n```\nelse\n```\n\n branch, you can also use a shorter logical \n\n```\n&&\n```\n\n syntax: \n\n```\n
    {isLoggedIn && }
    \n```\n\n All of these approaches also work for conditionally specifying attributes. If you’re unfamiliar with some of this JavaScript syntax, you can start by always using \n\n```\nif...else\n```\n\n. Rendering lists You will rely on JavaScript features like \n\n```\nfor\n```\n\n loop and the array \n\n```\nmap()\n```\n\n function to render lists of components. For example, let’s say you have an array of products: \n\n```\nconst products = [ { title: 'Cabbage', id: 1 }, { title: 'Garlic', id: 2 }, { title: 'Apple', id: 3 },];\n```\n\n Inside your component, use the \n\n```\nmap()\n```\n\n function to transform an array of products into an array of \n\n```\n
  • \n```\n\n items: \n\n```\nconst listItems = products.map(product =>
  • {product.title}
  • );return (
      {listItems}
    );\n```\n\n Notice how \n\n```\n
  • \n```\n\n has a \n\n```\nkey\n```\n\n attribute. For each item in a list, you should pass a string or a number that uniquely identifies that item among its siblings. Usually, a key should be coming from your data, such as a database ID. React uses your keys to know what happened if you later insert, delete, or reorder the items. App. js App. js Reload Clear Fork \n\n```\nconst products = [\n { title: 'Cabbage', isFruit: false, id: 1 },\n { title: 'Garlic', isFruit: false, id: 2 },\n { title: 'Apple', isFruit: true, id: 3 },\n];\nexport default function ShoppingList() {\n const listItems = products.map(product =>\n \n {product.title}\n
  • \n );\n return (\n
      {listItems}
    \n );\n}\n```\n\n Show more Responding to events You can respond to events by declaring event handler functions inside your components: \n\n```\nfunction MyButton() { function handleClick() { alert('You clicked me!'); } return ( );}\n```\n\n Notice how \n\n```\nonClick={handleClick}\n```\n\n has no parentheses at the end! Do not call the event handler function: you only need to pass it down. React will call your event handler when the user clicks the button. Updating the screen Often, you’ll want your component to “remember” some information and display it. For example, maybe you want to count the number of times a button is clicked. To do this, add state to your component. First, import \n\n```\nuseState\n```\n\n from React: \n\n```\nimport { useState } from 'react';\n```\n\n Now you can declare a state variable inside your component: \n\n```\nfunction MyButton() { const [count, setCount] = useState(0); // ...\n```\n\n You’ll get two things from \n\n```\nuseState\n```\n\n: the current state ( \n\n```\ncount\n```\n\n ), and the function that lets you update it ( \n\n```\nsetCount\n```\n\n ). You can give them any names, but the convention is to write \n\n```\n[something, setSomething]\n```\n\n. The first time the button is displayed, \n\n```\ncount\n```\n\n will be \n\n```\n0\n```\n\n because you passed \n\n```\n0\n```\n\n to \n\n```\nuseState()\n```\n\n. When you want to change state, call \n\n```\nsetCount()\n```\n\n and pass the new value to it. Clicking this button will increment the counter: \n\n```\nfunction MyButton() { const [count, setCount] = useState(0); function handleClick() { setCount(count + 1); } return ( );}\n```\n\n React will call your component function again. This time, \n\n```\ncount\n```\n\n will be \n\n```\n1\n```\n\n. Then it will be \n\n```\n2\n```\n\n. And so on. If you render the same component multiple times, each will get its own state. Click each button separately: App. js App. js Reload Clear Fork \n\n```\nimport { useState } from 'react';\nexport default function MyApp() {\n return (\n
    \n

    Counters that update separately

    \n \n \n
    \n );\n}\nfunction MyButton() {\n const [count, setCount] = useState(0);\n function handleClick() {\n setCount(count + 1);\n }\n return (\n \n );\n}\n```\n\n Show more Notice how each button “remembers” its own \n\n```\ncount\n```\n\n state and doesn’t affect other buttons. Using Hooks Functions starting with \n\n```\nuse\n```\n\n are called Hooks. \n\n```\nuseState\n```\n\n is a built-in Hook provided by React. You can find other built-in Hooks in the API reference. You can also write your own Hooks by combining the existing ones. Hooks are more restrictive than other functions. You can only call Hooks at the top of your components (or other Hooks). If you want to use \n\n```\nuseState\n```\n\n in a condition or a loop, extract a new component and put it there. Sharing data between components In the previous example, each \n\n```\nMyButton\n```\n\n had its own independent \n\n```\ncount\n```\n\n, and when each button was clicked, only the \n\n```\ncount\n```\n\n for the button clicked changed: Initially, each \n\n```\nMyButton\n```\n\n ’s \n\n```\ncount\n```\n\n state is \n\n```\n0\n```\n\n The first \n\n```\nMyButton\n```\n\n updates its \n\n```\ncount\n```\n\n to \n\n```\n1\n```\n\n However, often you’ll need components to share data and always update together. To make both \n\n```\nMyButton\n```\n\n components display the same \n\n```\ncount\n```\n\n and update together, you need to move the state from the individual buttons “upwards” to the closest component containing all of them. In this example, it is \n\n```\nMyApp\n```\n\n: Initially, \n\n```\nMyApp\n```\n\n ’s \n\n```\ncount\n```\n\n state is \n\n```\n0\n```\n\n and is passed down to both children On click, \n\n```\nMyApp\n```\n\n updates its \n\n```\ncount\n```\n\n state to \n\n```\n1\n```\n\n and passes it down to both children Now when you click either button, the \n\n```\ncount\n```\n\n in \n\n```\nMyApp\n```\n\n will change, which will change both of the counts in \n\n```\nMyButton\n```\n\n. Here’s how you can express this in code. First, move the state up from \n\n```\nMyButton\n```\n\n into \n\n```\nMyApp\n```\n\n: \n\n```\nexport default function MyApp() { const [count, setCount] = useState(0); function handleClick() { setCount(count + 1); } return (

    Counters that update separately

    );}function MyButton() { // ... we're moving code from here ...}\n```\n\n Then, pass the state down from \n\n```\nMyApp\n```\n\n to each \n\n```\nMyButton\n```\n\n, together with the shared click handler. You can pass information to \n\n```\nMyButton\n```\n\n using the JSX curly braces, just like you previously did with built-in tags like \n\n```\n\n```\n\n: \n\n```\nexport default function MyApp() { const [count, setCount] = useState(0); function handleClick() { setCount(count + 1); } return (

    Counters that update together

    );}\n```\n\n The information you pass down like this is called props. Now the \n\n```\nMyApp\n```\n\n component contains the \n\n```\ncount\n```\n\n state and the \n\n```\nhandleClick\n```\n\n event handler, and passes both of them down as props to each of the buttons. Finally, change \n\n```\nMyButton\n```\n\n to read the props you have passed from its parent component: \n\n```\nfunction MyButton({ count, onClick }) { return ( );}\n```\n\n When you click the button, the \n\n```\nonClick\n```\n\n handler fires. Each button’s \n\n```\nonClick\n```\n\n prop was set to the \n\n```\nhandleClick\n```\n\n function inside \n\n```\nMyApp\n```\n\n, so the code inside of it runs. That code calls \n\n```\nsetCount(count + 1)\n```\n\n, incrementing the \n\n```\ncount\n```\n\n state variable. The new \n\n```\ncount\n```\n\n value is passed as a prop to each button, so they all show the new value. This is called “lifting state up”. By moving state up, you’ve shared it between components. App. js App. js Reload Clear Fork \n\n```\nimport { useState } from 'react';\nexport default function MyApp() {\n const [count, setCount] = useState(0);\n function handleClick() {\n setCount(count + 1);\n }\n return (\n
    \n

    Counters that update together

    \n \n \n
    \n );\n}\nfunction MyButton({ count, onClick }) {\n return (\n \n );\n}\n```\n\n Show more Next Steps By now, you know the basics of how to write React code! Check out the Tutorial to put them into practice and build your first mini-app with React. Next Tutorial: Tic-Tac-Toe", - "metadata": { - "source_type": "general", - "quality_score": 9.5, - "coherence_score": 7.0, - "word_count": 2184, - "timestamp": "2025-09-03 07:32:46" - } - }, - { - "id": "5f4eea061c8d", - "url": "https://stackoverflow.com/questions/32646920/whats-the-at-symbol-in-the-redux-connect-decorator", - "title": "javascript - What's the '@' (at symbol) in the Redux @connect decorator? - Stack Overflow", - "content": "What's the '@' (at symbol) in the Redux @connect decorator? Ask Question Asked 9 years, 11 months ago Modified 8 years ago Viewed 68k times 238 I am learning Redux with React and stumbled upon this code. I am not sure if it is Redux specific or not, but I have seen the following code snippet in one of the examples. \n\n```\n@connect((state) => {\n return {\n key: state.a.b\n };\n})\n```\n\n While the functionality of \n\n```\nconnect\n```\n\n is pretty straightforward, but I don't understand the \n\n```\n@\n```\n\n before \n\n```\nconnect\n```\n\n. It isn't even a JavaScript operator if I am not wrong. Can someone explain please what is this and why is it used? Update: It is in fact a part of \n\n```\nreact-redux\n```\n\n which is used to connects a React component to a Redux store. javascript reactjs decorator redux Share Improve this question Follow edited Jun 11, 2016 at 4: 35 Felix Kling 819k 181 181 gold badges 1. 1k 1. 1k silver badges 1. 2k 1. 2k bronze badges asked Sep 18, 2015 at 8: 07 Salman 9, 467 6 6 gold badges 42 42 silver badges 74 74 bronze badges 4 6 I'm not familiar with Redux, but it looks like a decorator. medium. com/google-developers/… Lee – Lee 09/18/2015 08: 19: 52 Commented Sep 18, 2015 at 8: 19 4 I love how in this new JavaScript world you are staring at the code half of the time and thinking \"what part of the language syntax is this? \" MK. – MK. 11/29/2016 05: 11: 03 Commented Nov 29, 2016 at 5: 11 4 Lol, I'm way deep into redux and stuff now. But back then I didn't know the decorator syntax has nothing to do with redux. Its just JavaScript. Glad to see this question is helping a lot of people like me.: ) Salman – Salman 11/29/2016 12: 16: 55 Commented Nov 29, 2016 at 12: 16 1 Apparently the redux team discourages the use of connect as a decorator at the moment github. com/happypoulp/redux-tutorial/issues/87 Syed Jafri – Syed Jafri 02/26/2017 22: 15: 07 Commented Feb 26, 2017 at 22: 15 Add a comment | 2 Answers 2 Sorted by: Reset to default Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first) 384 The \n\n```\n@\n```\n\n symbol is in fact a JavaScript expression currently proposed to signify decorators: Decorators make it possible to annotate and modify classes and properties at design time. Here's an example of setting up Redux without and with a decorator: Without a decorator \n\n```\nimport React from 'react';\nimport * as actionCreators from './actionCreators';\nimport { bindActionCreators } from 'redux';\nimport { connect } from 'react-redux';\nfunction mapStateToProps(state) {\n return { todos: state.todos };\n}\nfunction mapDispatchToProps(dispatch) {\n return { actions: bindActionCreators(actionCreators, dispatch) };\n}\nclass MyApp extends React.Component {\n // ...define your main app here\n}\nexport default connect(mapStateToProps, mapDispatchToProps)(MyApp);\n```\n\n Using a decorator \n\n```\nimport React from 'react';\nimport * as actionCreators from './actionCreators';\nimport { bindActionCreators } from 'redux';\nimport { connect } from 'react-redux';\nfunction mapStateToProps(state) {\n return { todos: state.todos };\n}\nfunction mapDispatchToProps(dispatch) {\n return { actions: bindActionCreators(actionCreators, dispatch) };\n}\n@connect(mapStateToProps, mapDispatchToProps)\nexport default class MyApp extends React.Component {\n // ...define your main app here\n}\n```\n\n Both examples above are equivalent, it's just a matter of preference. Also, the decorator syntax isn't built into any Javascript runtimes yet, and is still experimental and subject to change. If you want to use it, it is available using Babel. Share Improve this answer Follow edited Jun 11, 2016 at 4: 31 Felix Kling 819k 181 181 gold badges 1. 1k 1. 1k silver badges 1. 2k 1. 2k bronze badges answered Sep 20, 2015 at 4: 56 Tanner Semerad Tanner Semerad 12. 7k 12 12 gold badges 43 43 silver badges 51 51 bronze badges 7 2 One can even be more terse with ES6 syntax. @connect( state = > { return { todos: state. todos }; }, dispatch = > { return {actions: bindActionCreators(actionCreators, dispatch)}; } ) LessQuesar – LessQuesar 10/24/2016 17: 46: 53 Commented Oct 24, 2016 at 17: 46 11 If you really want to be terse you can use implicit returns in ES6. It depends on how explicit you want to be. \n\n```\n@connect(state => ({todos: state.todos}), dispatch => ({actions: bindActionCreators(actionCreators, dispatch)}))\n```\n\n Tanner Semerad – Tanner Semerad 10/24/2016 18: 22: 09 Commented Oct 24, 2016 at 18: 22 3 How would you export the unconnected component for unit testing? tim – tim 04/13/2017 09: 30: 13 Commented Apr 13, 2017 at 9: 30 Using decorator for redux with react-navigation can be problematic, current best-practice is to use the function not the decorator: github. com/react-community/react-navigation/issues/1180 straya – straya 05/23/2017 03: 02: 16 Commented May 23, 2017 at 3: 02 The examples are really helpful Subhadeep Banerjee – Subhadeep Banerjee 06/27/2018 14: 16: 42 Commented Jun 27, 2018 at 14: 16 | Show 2 more comments 51 Very Important! These props are called state props and they are different from normal props, any change to your component state props will trigger the component render method again and again even if you don't use these props so for Performance Reasons try to bind to your component only the state props that you need inside your component and if you use a sub props only bind these props. example: lets say inside your component you only need two props: the last message the user name don't do this \n\n```\n@connect(state => ({ \n user: state.user,\n messages: state.messages\n}))\n```\n\n do this \n\n```\n@connect(state => ({ \n user_name: state.user.name,\n last_message: state.messages[state.messages.length-1]\n}))\n```\n\n Share Improve this answer Follow answered Apr 9, 2017 at 16: 53 Fareed Alnamrouti Fareed Alnamrouti 32. 3k 4 4 gold badges 90 90 silver badges 78 78 bronze badges 2 9 or use selectors like reselect or fastmemoize Julius Koronci – Julius Koronci 06/29/2017 06: 39: 25 Commented Jun 29, 2017 at 6: 39 survivejs. com/react/appendices/understanding-decorators and sitepoint. com/javascript-decorators-what-they-are zloctb – zloctb 10/29/2017 08: 52: 29 Commented Oct 29, 2017 at 8: 52 Add a comment | Your Answer Draft saved Draft discarded Sign up or log in Sign up using Google Sign up using Email and Password Submit Post as a guest Name Email Required, but never shown Post Your Answer Discard By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy. Start asking to get answers Find the answer to your question by asking. Ask question Explore related questions javascript reactjs decorator redux See similar questions with these tags. The Overflow Blog Open-source is for the people, by the people Building AI for consumer applications isn’t all fun and games Featured on Meta Community Asks Sprint Announcement - September 2025 Policy: Generative AI (e. g., ChatGPT) is banned New comment UI experiment graduation Linked 1 using higher order component in react class component 0 What does the '@' sign in front of a function do? 2 React-redux @connect does not work, but connect() does 4 react. js get child value in parent component 0 Building React/Redux Application 0 Which way should I use for Connector in Redux? 1 React Native Redux Reducer not working 0 Adding new item to array using spread operator in react redux not re-rendering the component Related 78 What does the at symbol (@) do in ES6 javascript? (ECMAScript 2015) 13 What is the use of @connect decorator in react-redux 0 why @ syntax is not working in react js 16 What is the @ symbol in TypeScript? 6 React-Redux @connect syntax error 0 Uable to understand function with @ symbol in react component 0 deciphering a export default connect statement in a react component 45 What does the @ symbol mean in a react import statement 0 Understanding the syntax of connect() function in react-redux 2 what is @ in react HOC? Hot Network Questions What did Jesus eat in relationship to his Jewish culture and tradition? Looking for a short story collection, history of the universe starting with the big bang Would this weapon be good for catching melee weapons? Do the Apollo probe/drogues also serve as an airtight seal when not docked, or is there a separate seal? Does the age limit for U. S. presidents apply at the the time of election or swearing in? PF2e: Raising a shield out of combat What do I do if a DB Bahn train is late for an OBB connection? Co-Lead Role Undermined, Manager Dismissive Comparative law: Does a lease transfer all benefits at once or gradually? Does Innate Sorcery grant Advantage to True Strike? How to prove that natural number less than is irrelevant? french interferes with iso time display What are the biblical arguments against the idea of a post-mortem opportunity for salvation? What should an airline pilot do in a decompression with a MEA of FL200? Did the Apollo Command Module launch with the docking probe already in place? Have there been any 20th century onwards notable rabbanim from the Indian Jewish community? How to merge two tables with a different amount of columns in one table? 90-00s TV show. Colony established on a habitable planet. Colony is surrounded by a large wall. Expedition outside the wall encounter exiled group c++ format_to verbosity Why is cinnamic acid nitrated at the ortho, para positions and not the meta position? What is the measure of the new angle? In \"Little Women\" (1949), what is the German song sung and played on the piano by Professor Bhaer? How can I attach the bottom of a window A. C. unit to the bottom of a window? Is it correct for a rotating uniform charged ring to have current? more hot questions Question feed lang-js", - "metadata": { - "source_type": "stackoverflow", - "quality_score": 9.5, - "coherence_score": 7.0, - "word_count": 1640, - "timestamp": "2025-09-03 07:33:08" - } - }, - { - "id": "aea45a48b743", - "url": "https://stackoverflow.com/questions/53389956/how-to-test-a-classname-with-the-jest-and-react-testing-library", - "title": "javascript - How to test a className with the Jest and React testing library - Stack Overflow", - "content": "How to test a className with the Jest and React testing library Ask Question Asked 6 years, 9 months ago Modified 1 year, 8 months ago Viewed 477k times 194 I am totally new to JavaScript testing and am working in a new codebase. I would like to write a test that is checking for a className on the element. I am working with Jest and React Testing Library. Below I have a test that will render a button based on the \n\n```\nvariant\n```\n\n prop. It also contains a className and I would like to test that. \n\n```\nit('Renders with a className equal to the variant', () => {\n const { container } = render(