React does not have computed properties out of the box like others frameworks do (Ember, Vue, etc.) so, how can we achieve this behaviour the right way ? The most common practice is to "compute" things in the render method if is a class component or just in the body if is a function component.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding=utf-8 | |
| # Copyright 2023 The HuggingFace Inc. team. All rights reserved. | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Wasp is a full-stack web app framework that uses React (for client), NodeJS and Prisma (for server). | |
| High-level of the app is described in main.wasp file (which is written in special Wasp DSL), details in JS/JSX files. | |
| Wasp DSL (used in main.wasp) reminds a bit of JSON, and doesn't use single quotes for strings, only double quotes. Examples will follow. | |
| Important Wasp features: | |
| - Routes and Pages: client side, Pages are written in React. | |
| - Queries and Actions: RPC, called from client, execute on server (nodejs). | |
| Queries are for fetching and should not do any mutations, Actions are for mutations. | |
| - Entities: central data models, defined via PSL (Prisma schema language), manipulated via Prisma. | |
| Typical flow: Routes point to Pages, Pages call Queries and Actions, Queries and Actions work with Entities. |
OlderNewer