[React] Research document for React #114
Labels
No labels
_CRITICAL_
API
app
backEnd
Blocked, waiting for further changes
bug
cleanup
close
design
duplicate
enhancement
feature request
frontEnd
help wanted
invalid
low priority
needs input
needs review
project documentation
question
research
reviewed
script
security
SQL
style
testing
topLevel
wontfix
No milestone
No project
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Andras/BoundlessFlowCampus2K#114
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
As React is a new technology for us a tutorial/general functionality documentation would be beneficial. Please add findings to comments.
React is a javascrip library, that is used for building UIs based on components.
Components are are JS functions (look at the functions in Card.js and TemperatureView.js) that return markup and are easily nested. An example is Card.js, which is used in TemperatureView.js, which in turn is used in App.js.
React uses the syntax extension JSX for creating markup. Since JSX is based on html, you can probably write them mostly the same, with the differance that you can embed JS expressions in your markup with {}, such as:
{person.name}
CSS styling can be imported from other files by adding "className=..." to an element. See Card.js and Card.module.css to see how this can be done.
Events, such as a button being pressed, can be handled by a handler function (either imported, or from the same component).
Another general functionality worth mentioning are hooks, which is basically allows react components to have a state and access some features, without being a class. Hook names start with use...
Here follows a brief explanation of the hooks used in the current state of the program (see useTemperature.js).
useState is used to preserve and update state variables in components.
const [value, setValue] = useState(initValue)
In this case value is the state variable that can be accessed and setValue is a function used to update value.
The useEffect hook is used to only fetch the API data once, instead of every time a component that uses useTemperature is rendered. This to avoid performance issues.
Here's a link that explains some of the built-in react hooks: https://react.dev/reference/react/hooks
I went through the React research document and the related comments to understand what has been covered so far.
Overall, it’s a good start and gives a basic introduction to React. It explains important concepts like components, JSX, styling, and hooks in a correct way. I also think it’s good that examples from the project (like Card.js, TemperatureView.js, and App.js) are used, since that makes it easier to connect the theory to what we are actually working with.
That said, there are a few things that could be improved to make the document clearer and more helpful, especially for someone new to React:
The structure could be clearer, for example by adding headings for different sections like Components, JSX, Styling, and Hooks.
Some parts feel a bit short and could use more explanation, especially for beginners.
It would be helpful to explain props and state more clearly, since they are core concepts in React.
Adding a few more concrete examples would make it easier to understand.
Overall, it’s a solid starting point, but with a bit more structure and detail it could become a really useful introduction to React for the team.
As this issue is very similar to #250, continued work on the research document will be added to the react wiki page instead.