Skip to content

Commit

Permalink
Filing a bug for React
Browse files Browse the repository at this point in the history
  • Loading branch information
metamn committed Aug 27, 2019
1 parent 3c2ffa4 commit 1dbed07
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 16 deletions.
3 changes: 1 addition & 2 deletions src/components/LoadingDataApiAxios/LoadingDataApiAxios.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const Article = styled(_Article)(props => ({
* Generates a text placeholder for articles
*/
const ArticlesPlaceholder = props => {
console.log("ArticlesPlaceholder");
/**
* Loads the placeholder
*/
Expand Down Expand Up @@ -81,7 +80,7 @@ const Articles = props => {
]);

/**
* Loads the data
* Loads data
*/
const { data } = useDataAPI(
articlesPlaceholder,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState, useMemo } from "react";
import PropTypes from "prop-types";
import styled from "styled-components";
import { Code } from "react-content-loader";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useMemo } from "react";
import PropTypes from "prop-types";
import styled from "styled-components";

Expand Down Expand Up @@ -79,10 +79,28 @@ const SettingsPlaceholder = props => {
* Loads site settings from the database
*/
const Settings = props => {
/**
* Loads props
*/
const { placeholder, displayData } = props;
const defaultProps = SettingsPlaceholder(placeholder);

/**
* Creates the placeholder
*/
const defaultProps = useMemo(() => SettingsPlaceholder(placeholder), [
placeholder
]);

/**
* Loads data
*/
const { data } = useData(defaultProps, query, "generalSettings");

/**
* Returns data
*
* If `displayData` then returns default data (for demo purposes)
*/
const { title, url, description } = displayData ? data : defaultProps;

return (
Expand Down
31 changes: 20 additions & 11 deletions src/components/PlaceholderText/PlaceholderText.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React, { useMemo } from "react";
import PropTypes from "prop-types";
import uuid from "uuid";

Expand Down Expand Up @@ -32,6 +33,7 @@ const defaultProps = {
* Displays the component
*/
const PlaceholderText = props => {
console.log("PlaceholderText");
/**
* Loads props
*/
Expand All @@ -40,22 +42,29 @@ const PlaceholderText = props => {
/**
* Generates a text row
*/
const textRow = [...Array(rowLength)].map(i => content).join("");
const textRow = useMemo(
() => [...Array(rowLength)].map(i => content).join(""),
[content, rowLength]
);

/**
* Generates the text rows
*/
const textRows = [...Array(numberOfRows)].map(i => {
/**
* Generates a random uuid
*/
const id = uuid.v4();
const textRows = useMemo(
() =>
[...Array(numberOfRows)].map(i => {
/**
* Generates a random uuid
*/
const id = uuid.v4();

return {
id: id,
text: textRow
};
});
return {
id: id,
text: textRow
};
}),
[numberOfRows, textRow]
);

return textRows;
};
Expand Down

0 comments on commit 1dbed07

Please sign in to comment.