aboutsummaryrefslogtreecommitdiff
path: root/src/debug/Test.tsx
blob: 660115453a7a936ecf1ae37f143ed7fe1c3965c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { serialize, deserialize, map } from 'serializr';
import { URLField, Doc } from '../fields/NewDoc';
import { SerializationHelper } from '../client/util/SerializationHelper';

class Test extends React.Component {
    onClick = () => {
        const url = new URLField(new URL("http://google.com"));
        const doc = new Doc();
        const doc2 = new Doc();
        doc.hello = 5;
        doc.fields = "test";
        doc.test = "hello doc";
        doc.url = url;
        doc.testDoc = doc2;

        console.log("doc", doc);
        const cereal = SerializationHelper.Serialize(doc);
        console.log("cereal", cereal);
        console.log("doc again", SerializationHelper.Deserialize(cereal));
    }

    render() {
        return <button onClick={this.onClick}>Click me</button>;
    }
}

ReactDOM.render(
    <Test />,
    document.getElementById('root')
);