Browse Source

fix-unique-key-warning

dev
ashawkey 5 years ago
parent
commit
6b291f07c6
  1. 14
      src/Common.js
  2. 1
      src/UserAction.js

14
src/Common.js

@ -66,8 +66,8 @@ export class HighlightedMarkdown extends Component {
const processInstructions = [ const processInstructions = [
{ {
shouldProcessNode: (node) => node.name === 'img', // disable images shouldProcessNode: (node) => node.name === 'img', // disable images
processNode (node) { processNode (node, children, index) {
return (<div>[图片]</div>) return (<div key={index}>[图片]</div>)
} }
}, },
{ {
@ -83,9 +83,9 @@ export class HighlightedMarkdown extends Component {
}, },
{ {
shouldProcessNode: (node) => node.name === 'a', shouldProcessNode: (node) => node.name === 'a',
processNode (node, children) { processNode (node, children, index) {
return ( return (
<a href={normalize_url(node.attribs.href)} target="_blank" rel="noopenner noreferrer" class="ext-link"> <a href={normalize_url(node.attribs.href)} target="_blank" rel="noopenner noreferrer" class="ext-link" key={index}>
{children} {children}
<span className="icon icon-new-tab" /> <span className="icon icon-new-tab" />
</a> </a>
@ -96,7 +96,7 @@ export class HighlightedMarkdown extends Component {
shouldProcessNode (node) { shouldProcessNode (node) {
return node.type === 'text' && (!node.parent || !node.parent.attribs || node.parent.attribs['encoding'] != "application/x-tex") // pid, nickname, search return node.type === 'text' && (!node.parent || !node.parent.attribs || node.parent.attribs['encoding'] != "application/x-tex") // pid, nickname, search
}, },
processNode (node) { processNode (node, children, index) {
const originalText = node.data const originalText = node.data
const splitted = split_text(originalText, [ const splitted = split_text(originalText, [
['url_pid', URL_PID_RE], ['url_pid', URL_PID_RE],
@ -106,7 +106,7 @@ export class HighlightedMarkdown extends Component {
]) ])
return ( return (
<> <React.Fragment key={index}>
{splitted.map(([rule, p], idx) => { {splitted.map(([rule, p], idx) => {
return (<span key={idx}> return (<span key={idx}>
{ {
@ -121,7 +121,7 @@ export class HighlightedMarkdown extends Component {
p} p}
</span>) </span>)
})} })}
</> </React.Fragment>
) )
} }
}, },

1
src/UserAction.js

@ -10,7 +10,6 @@ import {cache} from './cache';
import {API_VERSION_PARAM, THUHOLE_API_ROOT, API, get_json, token_param} from './flows_api'; import {API_VERSION_PARAM, THUHOLE_API_ROOT, API, get_json, token_param} from './flows_api';
import './UserAction.css'; import './UserAction.css';
import {ColorPicker} from "./color_picker";
const BASE64_RATE=4/3; const BASE64_RATE=4/3;
const MAX_IMG_DIAM=8000; const MAX_IMG_DIAM=8000;

Loading…
Cancel
Save