-
-
Notifications
You must be signed in to change notification settings - Fork 55
Adiciona página junte-se com renderização de arquivo MarkDown #86
Conversation
useEffect(() => { | ||
async function fetchFileAndSetState() { | ||
const response = await fetch(joinUsFile); | ||
const text = await response.text(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this await is really necessary? because, in my understanding response will have a value when arrive at this line
const text = await response.text(); | |
const text = response.text(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fetch returns a Response
object, and its body is a Readable Stream
. In the same way we need to use json
async method when we want this response's body as a JSON, in this case it's necessary to get the body as a text, so I decided to use text
method.
import joinUsFile from './JoinUs.md'; | ||
|
||
const JoinUsPage = () => { | ||
const [markDownText, setMarkDownText] = useState(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you put in a state? The markdown is static, so we don't need a state here, imo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By using a state, the page will render while the MarkDown text is being obtained by fetch
, and also I can pass its value as props for MarkDownRenderer
component.
@fanny I updated the description of how to add a repository to IssueAi with the future link of when your PR is merged. Because of this, it's temporarily broken. |
Fixes #80
Qual o propósito dessa pull request?
Esta PR adiciona uma nova página Junte-se a nós, que contém informações detalhadas de como ter um projeto opensource apoiado pela OpenDevUFCG.
O que foi feito?
Implementei uma nova rota
/junte-se
, e utilizei o react-markdown para a criação de um componente que serve para a renderização de arquivos MarkDown dentro de um outro componente React, conforme sugerido por @thayannevls. Todas as informações foram adicionadas num arquivoJoinUs.md
, que por sua vez, foi renderizado a partir do componente renderizador.Tipo de mudanças